Rectangular Array : Multiple dimensional array « Collections « VB.Net Tutorial






Option Strict On
 Imports System
 Class Tester
     Shared Sub Main()
         Const rowsUB As Integer = 4
         Const columnsUB As Integer = 3

         Dim rectangularArray(rowsUB, columnsUB) As Integer

         Dim i As Integer
         For i = 0 To rowsUB - 1
             Dim j As Integer
             For j = 0 To columnsUB - 1
                 rectangularArray(i, j) = i + j
             Next j
         Next i

         For i = 0 To rowsUB - 1
             Dim j As Integer
             For j = 0 To columnsUB - 1
                 Console.WriteLine( _
                   "rectangularArray[{0},{1}] = {2}", _
                   i, j, rectangularArray(i, j))
             Next j
         Next i
     End Sub
 End Class
rectangularArray[0,0] = 0
rectangularArray[0,1] = 1
rectangularArray[0,2] = 2
rectangularArray[1,0] = 1
rectangularArray[1,1] = 2
rectangularArray[1,2] = 3
rectangularArray[2,0] = 2
rectangularArray[2,1] = 3
rectangularArray[2,2] = 4
rectangularArray[3,0] = 3
rectangularArray[3,1] = 4
rectangularArray[3,2] = 5








8.7.Multiple dimensional array
8.7.1.Initialize two dimensional array by index
8.7.2.Initializing multi-dimensional arrays
8.7.3.Rectangular Array
8.7.4.Define and initialize the two dimensional array
8.7.5.Jagged two-dimensional array example.
8.7.6.Declare the jagged array as 4 rows high
8.7.7.Reference elements in two dimensional array
8.7.8.Use For Each/Next to find an element in a two dimension array
8.7.9.Set the array of arrays