How to trim a set of characters from a string in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string s = "  ********######**c# c++ c java****#######*   ";
        char[] trimChars = { '*', '#', ' ' };
        
        s = s.Trim(trimChars);
        
        Console.Write(s);
    }
}



/*
run:

c# c++ c java

*/

 



answered Jul 10, 2020 by avibootz

Related questions

1 answer 140 views
1 answer 104 views
104 views asked Jul 30, 2023 by avibootz
1 answer 184 views
1 answer 188 views
2 answers 263 views
1 answer 208 views
208 views asked Jan 20, 2017 by avibootz
1 answer 78 views
78 views asked Aug 15, 2023 by avibootz
...