This is as simple as
myString.Trim(new char[] {','}
, but can you rather think about how to avoid adding redundant comma in first place?
So, please see
http://msdn.microsoft.com/en-us/library/d4tt83f9.aspx[
^], but think about it.
Remember that strings are
immutable, so all string operations like that mean creation of the brand new string with copying all the data back and forth. That's why
System.Text.StringBuilder
is better for string manipulations, but it won't help you much if you already produced the string which needs some fix. Try to avoid it in first place. Or — forget it and use
Trim
if performance is not an issue.
—SA