How to trim whitespace from a string in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string str = "  c# vb.net java c  ";
        
        str = str.Trim();
        
        Console.WriteLine(str); 
    }
}




/*
run:

c# vb.net java c

*/

 



answered Jul 30, 2023 by avibootz

Related questions

1 answer 186 views
186 views asked Jul 30, 2023 by avibootz
1 answer 236 views
236 views asked Aug 3, 2020 by avibootz
1 answer 212 views
3 answers 435 views
1 answer 229 views
...