Search code examples
c#stringtrim

How to remove the last specific character in a string


I use WinForms C#. I have a string value like below:

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

I need to remove the last comma in this string. So how can I delete it?


Solution

  • Try string.TrimEnd():

    Something = Something.TrimEnd(',');