remove char from string c# code example

Example 1: c# remove word from string

public static string RemoveHTML(string text)
{
    text = text.Replace(" ", " ").Replace("<br>", "\n").Replace("description", "").Replace("INFRA:CORE:", "")
        .Replace("RESERVED", "")
        .Replace(":", "")
        .Replace(";", "")
        .Replace("-0/3/0", "");
        var oRegEx = new System.Text.RegularExpressions.Regex("<[^>]+>");
        return oRegEx.Replace(text, string.Empty);
}

Example 2: c# remove first 5 characters from string

str = str.Substring(n); //Where n is the number of characters you want to remove

Example 3: c# remove specific character from string

string phrase = "this is, a string with, too many commas";
phrase = phrase.Replace(",", "");

Example 4: remove control characters from string c#

string input; // this is your input string
string output = new string(input.Where(c => !char.IsControl(c)).ToArray());

Tags:

Vb Example