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 271 views
271 views asked Jul 30, 2023 by avibootz
1 answer 324 views
324 views asked Aug 3, 2020 by avibootz
1 answer 300 views
3 answers 584 views
1 answer 329 views
...