TrimEnd() not working

Viewed 24298

I want to trim the end off a string if it ends in ", ". That's a comma and a space.

I've tried TrimEnd(', '), but this doesn't work. It has to be only if the string ends this way, so I can't just use .Remove to remove the last two characters. How can I do it?

6 Answers

The catch is that mystring.Trim(',') will only work if you reassign it to the string itself like this:

mystring = mystring.Trim(',')

"value, ".Trim().TrimEnd(",") should also work.

Related