EnumerableExtensions.

IsNullOrEmpty<T>(IEnumerable<T>) Method

Summary

Checks whether specified IEnumerable is null or contains no elements

Syntax

public static bool IsNullOrEmpty<T>(this IEnumerable<T> source)

Examples

Replace
collection == null || !collection.Any()
with
collection.IsNullOrEmpty()

Type Parameters

Name Description
T the item type

Parameters

Name Type Description
source IEnumerable<T> the collection

Return Value

Type Description
bool true if element null or empty, else false