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 ...
Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.