Thursday, 12 September 2013

Remove a single space from a string

Remove a single space from a string

"How do I do this? "
Let's say I have this string. How do I remove only one space from the end?
The code shown below gives me an error saying the count is out of range.
string s = "How do I do this? ";
s = s.Remove(s.Length, 1);

No comments:

Post a Comment