IsNullOrEmpty
Checks if the collection is null or empty
Source
public static bool IsNullOrEmpty(this System.Collections.Generic.IEnumerable<T> source)
{
return source = null || !source.Any();
}
Example
string[] strArr = null;
int[] intArr = {};
bool[] booArr = {true, false};
bool result1 = strArr.IsNullOrEmpty(); //returns true
bool result2 = intArr.IsNullOrEmpty(); //returns true
bool result3 = booArr.IsNullOrEmpty(); //returns false
Author: Linquize
Submitted on: 5 feb. 2011
Language: C#
Type: System.Collections.Generic.IEnumerable<T>
Views: 5393