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


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


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


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: 13812