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 273 views
273 views asked Jul 30, 2023 by avibootz
1 answer 325 views
325 views asked Aug 3, 2020 by avibootz
1 answer 301 views
3 answers 584 views
1 answer 330 views
...