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

IsNullOrEmpty

Indicates whether the specified IEnumerable collection is null or empty

Source

public static bool IsNullOrEmpty(this IEnumerable iEnumerable)
{
    if (iEnumerable != null)
    {
        return !iEnumerable.GetEnumerator().MoveNext();
    }
    return true;
}

Example

List<string> list = new List<string>();
Console.WriteLine(list.IsNullOrEmpty());

Author: Avi Harush

Submitted on: 24 dec. 2009

Language: C#

Type: System.Collections.IEnumerable

Views: 4817