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
Post a Comment