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

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
       string str = "***---=====c# c c++*******========";
       
       char[] characters = { '*', '-', '=' };
       
       str = str.Trim(characters);
       
       Console.WriteLine(str);
    }
}




/*
run

c# c c++

*/

 



answered Aug 8, 2022 by avibootz
...