ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

IsNotNullOrEmpty

It returns false if given collection is null or empty otherwise it returns true.

Source

public static bool IsNotNullOrEmpty(this System.Collections.Generic.IEnumerable<T> source)
{
    return source != null && source.Any();
}

Example

var list = new List<string>();
Assert.IsFalse( list.IsNotNullOrEmpty());


List<string> list = null;
Assert.IsFalse( list.IsFalseNullOrEmpty());

var list = new[] {"One, Two"};
Assert.IsTrue( list.IsNotNullOrEmpty());

Author: Omkar Panhalkar

Submitted on: 7 mei 2012

Language: C#

Type: System.Collections.Generic.IEnumerable<T>

Views: 13691