How to check if a string contain only spaces in C#

1 Answer

0 votes
using System;
 
class Program
{
    static void Main() {
        string str1 = "      ";
        string str2 = "  ";
 
        Console.WriteLine(string.IsNullOrWhiteSpace(str1));
        Console.WriteLine(string.IsNullOrWhiteSpace(str2));     
    }
}
   


   
   
/*
run:
   
True
True
   
*/

 



answered Sep 13, 2023 by avibootz

Related questions

1 answer 139 views
1 answer 134 views
1 answer 171 views
1 answer 185 views
1 answer 186 views
...