CSharp examples for System.Collections.Generic:ICollection
Checks whether or not collection is null or empty. Assumes collection can be safely enumerated multiple times.
using System.ComponentModel; using System.Collections.Generic; using System.Collections; using System;//from w w w . ja v a 2s .c o m public class Main{ /// <summary> /// Checks whether or not collection is null or empty. Assumes collection can be safely enumerated multiple times. /// /// </summary> /// <param name="this"/> /// <returns/> public static bool IsNullOrEmpty(this IEnumerable @this) { if (@this != null) return !@this.GetEnumerator().MoveNext(); else return true; } }