Remove last specific character in a string c#

user3042186 picture user3042186 · Nov 27, 2013 · Viewed 120.2k times · Source

I use WinForms c#.I have string value like below,

string Something = "1,5,12,34,";

I need to remove last comma in a string. So How can i delete it ?

Answer

King King picture King King · Nov 27, 2013

Try string.TrimEnd():

Something = Something.TrimEnd(',');