IsNullOrEmptyOrWhiteSpace

public static bool IsNullOrEmptyOrWhiteSpace(this string input)
{
   return string.IsNullOrEmpty(input) || input.Trim() == string.Empty;
}
Example:
Assert.IsTrue(IsNullOrEmptyOrWhiteSpace(null));
Assert.IsTrue(IsNullOrEmptyOrWhiteSpace(string.Empty));
Assert.IsTrue(IsNullOrEmptyOrWhiteSpace("   "));
Assert.IsFalse(IsNullOrEmptyOrWhiteSpace("TestValue"));

Description

It returns true if string is null or empty or just a white space otherwise it returns false.

Details

Double click on the code to select all.

 

;