c# remove all instances of character from string code example
Example 1: remove all text after string c#
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 ?
Example 2: c# remove all punctuation from string
string output = new string(OriginalString.Where(c => !char.IsPunctuation(c)).ToArray());