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

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.
 
L

Lyny

try this:
string MyString = " abc ,";

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

Console.WriteLine("The answer is '{0}'", MyString);
 
G

garyusenet

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top