C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# String IsNullOrWhiteSpace()The C# IsNullOrWhiteSpace() method is used to check whether the specified string is null, or consists only of white-space characters. It returns boolean value either True or False. Signaturepublic static bool IsNullOrWhiteSpace(String str) Parameterstr: it is a string parameter which is used to check null, white-space in string. ReturnIt returns boolean value. C# String IsNullOrWhiteSpace() Method Example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello C#";
string s2 = "";
string s3 = " ";
bool b1 = string.IsNullOrWhiteSpace(s1);
bool b2 = string.IsNullOrWhiteSpace(s2);
bool b3 = string.IsNullOrWhiteSpace(s3);
Console.WriteLine(b1); // returns False
Console.WriteLine(b2); // returns True
Console.WriteLine(b3); // returns True
}
}
Output: False True True
Next TopicC# String Join()
|