Creating Arrays

Array instances are created by field or local variable declaration.

When an array instance is created, the rank and length of each dimension are established and then remain constant. In other words, it is not possible to change the rank of an existing array instance, nor is it possible to resize its dimensions. A default value is assigned to created array elements. Element values can also be determined at array initialization.

Example 1

Array instances creation:

Sub ArraySample();
Var
    //Array declaration
    Arr1: array Of integer;
    //Array instance creation at variable declaration stage
    Arr2: array Of integer = New integer[5];
    Arr3: array[, , ] Of integer = New integer[333];
Begin
    //Creating an array instance
    Arr1 := New integer[5];
End Sub;

Example 2

Values initialization at array declaration:

Sub ArraySample1();
Var
    Arr1: array Of integer = New integer[5] = [12345];
    Arr2: array[5Of integer = [12345];
    Arr3: array[-3..3Of integer = [1234567];
    Arr4: array[42Of integer = [[12], [34], [56], [78]];
    Arr5: array[32..4Of integer = [[111], [222], [333]];
    Arr6: array[2, ] Of integer = New integer[23] = [[123], [456]];
    Arr7: array[333Of integer =
        [[[111], [112], [113]],
        [[211], [222], [223]],
        [[311], [322], [333]]];
Begin
    
End Sub;

See also:

Arrays