Get Length of IEnumerable - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IEnumerable

Description

Get Length of IEnumerable

Demo Code


using System.Collections.Generic;
using System.Collections;
using System;/*from  ww  w  .  ja  v a  2s  .com*/

public class Main{
        public static int GetLength(IEnumerable collection)
        {
            int ret = 0;
            if (collection != null)
                foreach (object o in collection)
                {
                    ret += 1;
                }
            return ret;
        }
}

Related Tutorials