1.

Explain Jagged arrays in VB.NET.

Answer»

An array of arrays array named scores of Integers is demonstrated in the code below.  is called a Jagged array. Declaring a jagge:

Dim marks As Integer()() = New Integer(10)(){}

The example code SNIPPET below shows how to use a jagged array:

Module demoArray Sub MAIN() ' making one jagged array of 3 arrays of integers Dim arr As Integer()() = New Integer(2)() {} arr(0) = New Integer() {5, 6} arr(1) = New Integer() {15, 10} arr(2) = New Integer() {32, 60} Dim a, b As Integer ' printing the value of every array ELEMENT  For a = 0 To 3 For b = 0 To 1 Console.WriteLine("arr[{0},{1}] = {2}", a, b, arr(a)(b)) Next b Next a Console.ReadKey() End SUBEND Module

The OUTPUT of the above code snippet will be as follows:

arr[0][0]: 5arr[0][1]: 6arr[1][0]: 15arr[1][1]: 10arr[2][0]: 32arr[2][1]: 60


Discussion

No Comment Found