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 95 views
1 answer 63 views
63 views asked Jul 30, 2023 by avibootz
1 answer 146 views
1 answer 145 views
2 answers 175 views
1 answer 170 views
170 views asked Jan 20, 2017 by avibootz
...