How to check if string is null or empty

To check if string is null or empty we use IsNullOrEmpty method.This method returns Boolean value. If string is null or is empty it will return true otherwise false.

string Name = "";
if (string.IsNullOrEmpty(Name))
{
    Console.WriteLine("Name is null or empty");

}

Output

Name is null or empty

Comments

Popular posts from this blog

Check if ViewBag is null or doesn't exist

Using Progress Bar In C#

Jquery serer side datatables in asp.net