How to remove the leading and trailing commas from a string in C#

1 Answer

0 votes
using System;
 
public class Program
{
    static void Main(string[] args)
    {
        string str = ",,,C#,,";
        
        str = str.Trim(',');
        
        Console.WriteLine(str);  
    }
}


 
/*
run:

C#
     
*/

 



answered Mar 6, 2025 by avibootz

Related questions

3 answers 128 views
2 answers 110 views
3 answers 127 views
2 answers 93 views
...