Multidimensional Array in VB.NET
How to use multidimensional array in VB.NET?
Explanation
Multi Dimensional Array
Multidimensional array is an array in which each element acts as an array that are represented as row and columns.
Example:
Module Module1
Sub Main()
Dim arr(3, 2) As String
Dim i As Integer
Dim j As Integer
arr(1, 1) = "COSCO"
arr(1, 2) = "Football"
arr(2, 1) = "NIKE"
arr(2, 2) = "Boots"
arr(3, 1) = "ADDIDAS"
arr(3, 2) = "Spikes"
For i = 1 To 3
For j = 1 To 2
System.Console.WriteLine(arr(i, j))
Next
Next
Console.ReadLine()
End Sub
End Module
Result:
COSCO
Football
NIKE
Boots
ADDIDAS
Spikes
Description:
In the above example using a multi dimensional array of string datatype, all the elements are retreived
using a loop and displayed in the console. This array can be also said to be a
Rectangular Array since it contains the
same number of rows and columns.