June 2006
Intermediate to advanced
1344 pages
42h 52m
English
Jagged arrays are maintained as arrays of arrays. Unlike rectangular arrays, rows in jagged arrays can be of different lengths. The program in Fig. 8.20 demonstrates the initialization of a jagged array (array1) and the use of nested For...Next loops to traverse the array.
1 ' Fig. 8.20: JaggedArray.vb 2 ' Initializing a jagged array. 3 Module JaggedArray 4 Sub Main() 5 ' create jagged array 6 Dim array1 As Integer()() = New Integer(2)(){}' three rows 7 array1(0) = New Integer() {1, 2} ' row 0 is a single array 8 array1(1) = New Integer() {3} ' row 1 is a single array 9 array1(2) = New Integer() {4, 5, 6} ' row 2 is a single array 10 11 Console.WriteLine("Values in jagged array1 ... |
Read now
Unlock full access