remove control characters from string csharp

Code Example - remove control characters from string csharp

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

remove all text after string csharp

                        
                                string input = "text?here";
int index = input.LastIndexOf("?"); // Character to remove "?"
if (index > 0)
    input = input.Substring(0, index); // This will remove all text after character ?
                            
                        
 

remove character from string csharp

                        
                                // our string
string myString = "test@gmail.com";

// lets remove the @ symbol
// here we replace our "@" in our string to an empty string 
string newString = myString.Replace("@", string.empty);
 
Console.Writeline(newString);
// output should look like this: testgmail.com
                            
                        
 

csharp remove char from string

                        
                                // How to replace a char in string with an Empty character
string num = "1234-1234-1234-1234";
num = num.Replace("-", " ");
// result: 1234 1234 1234 1234

// How to remove a char in string
string num = "1234-1234-1234-1234";
num = num.Replace("-", string.Empty);
// result: 1234123412341234
                            
                        
 

csharp remove character from string at index

                        
                                string s = "This is string";
s = s.Remove(2, 1);
//Output: Ths is string


string s = "This is string";
s = s.Remove(2, 2);
//Output: Th is string
                            
                        
 

csharp Remove String In csharp

                        
                                //The following example removes all characters from a string that are after 25th position in the string.

string founder = "Mahesh Chand is a founder of C# Corner";  
// Remove all characters after first 25 chars  
string first25 = founder.Remove(25);  
Console.WriteLine(first25);  
//************************************   ^_*
//The following example removes 12 characters from the 10th position in the string.

// Remove characters start at the 10th position, next 12 characters  
String newStr = founder.Remove(10, 12);  
Console.WriteLine(newStr);
                            
                        
 

csharp 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);
}