how to trim off trailing spaces and or commas from a string - thankyou

  • Thread starter Thread starter garyusenet
  • Start date Start date
G

garyusenet

In my continuing education regarding string manipulation,

can someone advise me how to take any trailing spaces, and commas from
a string.

these strings are comming from the streamreader

for instance.

string 1 = 'abcd '
string 2 = 'abc,'

and i want the string mapped to string1 to read 'abcd'
and the string mapped to string2 to read 'abc'

Many Thanks,

Gary.
 
try this:
string MyString = " abc ,";

MyString = MyString.Trim(' ', ',');

Console.WriteLine("The answer is '{0}'", MyString);
 
Thankyou both that's exactly what i wanted.

it never ceases to amaze me how much functionality is built into the
Libraries as standard.

Thanks,

Gary.
 
Back
Top