Is the given array null of does it have a count of 0? - CSharp System

CSharp examples for System:Array Null Element

Description

Is the given array null of does it have a count of 0?

Demo Code


using System.Linq;
using System.Collections.Generic;
using System;//from   w w  w  .  jav a  2 s . com

public class Main{
        /// <summary>
        /// Is the given array null of does it have a count of 0?
        /// </summary>
        public static bool IsEmpty<T>(this T[] array)
        {
            return (array == null) || (array.Length == 0);
        }
        /// <summary>
        /// Is the given list null of does it have a count of 0?
        /// </summary>
        public static bool IsEmpty<T>(this IList<T> list)
        {
            return (list == null) || (list.Count == 0);
        }
}

Related Tutorials