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 145 views
2 answers 121 views
1 answer 101 views
3 answers 134 views
2 answers 102 views
...