new int[,] {{0, 1}, {2, 3}, {4, 5}}exactly corresponds to
new int[3, 2] {{0, 1}, {2, 3}, {4, 5}}Paragraph 61 Array initializers are described further in §19.6. Paragraph 71 The result of evaluating an array creation expression is classified as a value, namely a reference to the newly allocated array instance. 2 The run-time processing of an array creation expression consists of the following steps:
int[][] a = new int[100][];creates a single-dimensional array with 100 elements of type int[]. The initial value of each element is null. end example] 2 It is not possible for the same array creation expression to also instantiate the sub-arrays, and the statement
int[][] a = new int[100][5]; // Errorresults in a compile-time error. 3 Instantiation of the sub-arrays must instead be performed manually, as in
int[][] a = new int[100][]; for (int i = 0; i < 100; i++) a[i] = new int[5];Paragraph 91 When an array of arrays has a "rectangular" shape, that is when the sub-arrays are all of the same length, it is more efficient to use a multi-dimensional array. 2 In the example above, instantiation of the array of arrays creates 101 objects-one outer array and 100 sub-arrays. 3 In contrast,
int[,] = new int[100, 5];creates only a single object, a two-dimensional array, and accomplishes the allocation in a single statement.
| |
Jagger Software Ltd | |
Company # 4070126 | |
VAT # 762 5213 42 |