For fast enumerations, this must be a IList of ILists, not a IList of IEnumerables - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IList

Description

For fast enumerations, this must be a IList of ILists, not a IList of IEnumerables

Demo Code


using System.Runtime.InteropServices;
using System.Reflection;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System;/*from  w  w w  .  j  a va 2s .  c  om*/

public class Main{
        /// <summary>
        /// For fast enumerations, this must be a IList of ILists, not a IList of IEnumerables
        /// </summary>
        /// <param name="enumerable"></param>
        /// <returns></returns>
        public static bool IsIListOfILists(IEnumerable<object> enumerable)
        {
            if (!(enumerable is IList)) return false; 
            IList<object> parent = enumerable as IList<object>;
            List<int> dimensionList = new List<int>();
            for (int i = 0; i < parent.Count; ++i)
            {
                if (!(parent[i] is IList<object>)) return false; 
            }
            return true;
        }
}

Related Tutorials