Isnullorwhitespace() - C# Tutorial
C# Course / Advanced Topics / Isnullorwhitespace()

Isnullorwhitespace()

BLUF: Mastering Isnullorwhitespace() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: Isnullorwhitespace()

C# is a powerful, modern language for enterprise solutions. Discover how Isnullorwhitespace() enhances your development workflow in the guide below.

The C# IsNullOrWhiteSpace function is employed to verify if the provided string is either null or composed solely of white-space characters, providing a Boolean outcome of True or False.

Signature

Example

public static bool IsNullOrWhiteSpace(String str)

Parameter

The variable str is a parameter of type string that is employed to verify if the string is null or contains only white spaces.

Return

It returns boolean value.

C# String IsNullOrWhiteSpace Method Example

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:

Output

False
True
True

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience