c# replace a character in a 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 sharp string replace
// You can use the function 'Replace()' to replace all instances
// of a string or character with a given string or character.
str = "Hello World!"
str.Replace('o', 'e');
// Output: "Helle Werld!"