Initializing jagged arrays
I want to create array 10 * 10 * 10 in C# like int[][][] (not int[,,] ). I can write code: int[][][] count = new int[10][][]; for (int i = 0; i < 10; i++) { count[i] = new int[10][]; for (int j = 0; j < 10; j++) count[i][j] = new int[10]; } but I am looking for a more beautiful way for it. May be something like that: int[][][] count = new int[10][10][10]; int[][][] my3DArray = CreateJaggedArray<int[][][]>(1, 2, 3); using static T CreateJaggedArray<T>(params int[] lengths) { return (T)InitializeJaggedArray(typeof(T).GetElementType(), 0, lengths); } static object InitializeJaggedArray(Type type,