String - IsNotNullOrWhiteSpace
Indicates whether a specified string is not null, not empty, or not consists only of white-space characters.
public static void Main() { string [] values = {"EntityFramework", " ", "SQL", "", "Java", null}; foreach(var str in values) { // C# Extension Method: String - IsNotNullOrWhiteSpace if(str.IsNotNullOrWhiteSpace()) { Console.WriteLine(str); } } }
View Source
using System; public static partial class Extensions { /// <summary> /// Indicates whether a specified string is not null, not empty, or not consists only of white-space characters. /// </summary> /// <param name="value">The string to test.</param> /// <returns>true if the parameter is null or , or if consists exclusively of white-space characters.</returns> public static Boolean IsNotNullOrWhiteSpace(this string value) { return !String.IsNullOrWhiteSpace(value); } }