O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.4. Mixing jagged and rectangular arrays

Developers who have mastered arrays, and want to put some complexity into their multi-dimensional arrays, can mix jagged and rectangular arrays. [7] Here is an example.

[7] I personally wouldn't do too much of this unless there really is good justification for doing so (such as sabotaging your colleague who is taking over your codes!).

int[][,] MessyArray = new int [3][,]

{

new int[,] { {1,3}, {5,7} },

new int[,] { {0,2}, {4,6}, {8,10} },

new int[,] { {11,22,33}, {77,88,99} }

};

This statement creates an int array called MessyArray, which is an array of two arrays. The first is an array of size 3 – call them 3a, 3b, and 3c. 3a is a 2D array containing 2 rows of 2 cells each. 3b is a 2D array containing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required