How to trim the last comma delimiter of a string in C#

1 Answer

0 votes
using System;

public class Program
{
    public static void Main()
    {
        string s = "c c++, java, php python, c#,";

        string comma = ",";

        s = s.TrimEnd(System.Convert.ToChar(comma));

        Console.Write(s);
    }
}




/*
run:

c c++, java, php python, c#

*/

 



answered Apr 18, 2022 by avibootz

Related questions

1 answer 148 views
1 answer 107 views
1 answer 136 views
1 answer 149 views
1 answer 198 views
...