CSharp examples for System.Collections:IEnumerable
Dimensions Of Jagged IEnumerable
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 av a2s .c o m public class Main{ private static int[] DimensionsOfJaggedIEnumerable(IEnumerable<object> enumerable) { int rank = 0; IEnumerable<object> parent = enumerable; List<int> dimensionList = new List<int>(); while (parent != null) { rank++; int count = parent.FastCount(); dimensionList.Add(count); parent = count == 0 ? null : parent.First() as IEnumerable<object>; } return dimensionList.ToArray(); } }