Export (0) Print
Expand All

How to: Create an Array of Arrays

An array with arrays for elements is called an array of arrays, or a jagged array. As with a one-dimensional array, you create it with a New (Visual Basic) clause and assign it to the array variable. You can do this as part of the array declaration, or in a subsequent assignment statement.

To create a jagged array

  1. Add as many pairs of parentheses after the variable name as there are levels of nested arrays.

  2. Add the same number of pairs of parentheses to the New clause. You do not need more than one pair of braces ({}) if you are not supplying any element values. The following example declares a variable to hold an array of arrays with elements of the Byte Data Type (Visual Basic), creates the array, and assigns it to the variable.

    Dim ratings As Byte()() = New Byte()() {}
    

    Following the execution of this statement, the array in variable ratings has length 0.

Community Additions

ADD
Show:
© 2014 Microsoft