All about Arrays in C#—Jagged Arrays
| Visual C# Tutorials |
| C# Tutorials |
| © 2006 Christian Gross |
Jagged Arrays
A jagged array is an array of arrays. Unlike rectangular arrays, the sub-arrays of a jagged array can have different numbers of elements.
For example, the following code declares a two-dimensional jagged array. The array’s layout in memory is shown in Figure 14-10.
- The length of the first dimension is 3.
- The declaration can be read as "
jagArris an array of three arrays ofints."
- The declaration can be read as "
- Notice that the figure shows four array objects—one for the top-level array, and three for the sub-arrays.
// Declare and create top-level array. int[][] jagArr = new int[3][]; // Declare and create sub-arrays. ...

Figure 14-10. A jagged array is an array of arrays.
|

