Multi-Dimensional Arrays
Rectangular Arrays - These are really 2 dimensional. The number of rows is identical to the number of columns.
Jagged Arrays - These are not really 2 dimensional and represent a 1 dimensional array of 1 dimensional arrays. Each element in the main array can hold an array of varying length.
Arrays with mutiple dimensions are also referred to as jagged arrays.
string[,] asMulti = new string[5,5];
Conceptually, a multidimensional array with two dimensions resembles a grid. A multidimensional array with three dimensions resembles a cube.
int[,] array2D = new int[2,3];
int[,] array2D2 = { {1, 2, 3}, {4, 5, 6} };
for (int i=0; i<2; i++)
{
for (int j=0; j<3; j++)
{
array2D[i,j] = (i + 1) * (j + 1);
}
}
for (int i=0; i<2; i++)
{
for (int j=0; j<3; j++)
{
System.Console.Write(array2D[i,j]);
}
System.Console.WriteLine();
}
int[] numbers = { 4, 5, 6, 1, 2, 3, -2, -1, 0 };
foreach (int i in numbers)
{
System.Console.Write("{0} ", i);
}
Matrices
Arrays that have two dimensions are called matrices Rectangular arrays of numbers are called matrices
Jagged Arrays
A jagged array is an array whose elements are arrays, possibly of different sizes.
A jagged array is sometimes called an "array of arrays."
link - learn.microsoft.com/en-us/dotnet/csharp/programming-guide/arrays/jagged-arrays
A variation of the multidimensional array is the jagged array: an array of arrays.
A jagged array is a single-dimensional array, and each element is itself an array.
The element arrays are not required to all be of the same size.
You declare a jagged array like this:
int[][] jaggedArray = new int[3][];
jaggedArray[0] = new int[5];
jaggedArray[1] = new int[4];
jaggedArray[2] = new int[2];
VB.Net - Syntax
Dim asMulti(5,5) As String
GetLowerBound - Get the upper bound of the specified dimension. Starting at the number 0.
GetUpperBound - Get the lower bound of the specified dimension. Starting at the number 0.
Dim asTableValues(10, 200) As String
Dim asTableValues As String()
asTableValues.GetUpperBound(0) = 10
asTableValues.GetUpperBound(1) = 200
Dim icolumnnumber As Integer
For icolumnnumber = 0 To asArrayName.GetUpperBound(0)
Next icolumnnumber
Dim irowcount As Integer
For irowcount = 0 To asArrayName.GetUpperBound(1)
Next irowcount
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext