EN
C#/.NET - remove characters from string
3
points
In C#/.NET it is possible to remove string characters with String.Remove
method.
1. Remove last character example
string text = "abc";
//string result = text.Remove(text.Length - 1, 1);
string result = text.Substring(0, text.Length - 1);
Console.WriteLine(text);
Output:
ab
2. Remove all characters after character position example
string text = "abc";
string result = text.Remove(1);
Console.WriteLine(result);
Output:
a
3. Remove all characters between character positions example
String text = "abc";
String result = text.Remove(1, 1);
Console.WriteLine(result);
Output:
ac