Define and initialize the multi-dimensional array : Array Multi Dimension « Data Structure « VB.Net






Define and initialize the multi-dimensional array

Define and initialize the multi-dimensional array
 
Imports System

Public Class MainClass
    
    Shared Sub Main()
     Const rowsUB As Integer = 4
     Const columnsUB As Integer = 3

     Dim rectangularArray As Integer(,) = _
        {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {9, 10, 11}}

     'report the contents of the array
     Dim i As Integer
     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


           
         
  








Related examples in the same category

1.Initializing a jagged array, one in which the length of each array differsInitializing a jagged array, one in which the length of each array differs
2.Seclare a 4x3 Integer arraySeclare a 4x3 Integer array
3.Array Performance Test: Two-dimensional arrayArray Performance Test: Two-dimensional array
4.Array Performance Test: Two-dimensional Array and SetValue(i, i)Array Performance Test: Two-dimensional Array and SetValue(i, i)
5.Two Dimensional Rectangle ArrayTwo Dimensional Rectangle Array
6.Define and Init two dimensional arrayDefine and Init two dimensional array
7.Initializing multidimensional arrays: rectangular two-dimensional arrayInitializing multidimensional arrays: rectangular two-dimensional array
8.Jagged two-dimensional arrayJagged two-dimensional array
9.Two dimension array DemoTwo dimension array Demo
10.Array.SetValue for two-dimensional array
11.Array.SetValue for three-dimensional array
12.Array.SetValue for a seven-dimensional array
13.Clear multi-dimensional array