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.
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[3, 3, 3];
Begin
//Creating an array instance
Arr1 := New integer[5];
End Sub;
Values initialization at array declaration:
Sub ArraySample1();
Var
Arr1: array Of integer = New integer[5] = [1, 2, 3, 4, 5];
Arr2: array[5] Of integer = [1, 2, 3, 4, 5];
Arr3: array[-3..3] Of integer = [1, 2, 3, 4, 5, 6, 7];
Arr4: array[4, 2] Of integer = [[1, 2], [3, 4], [5, 6], [7, 8]];
Arr5: array[3, 2..4] Of integer = [[1, 1, 1], [2, 2, 2], [3, 3, 3]];
Arr6: array[2, ] Of integer = New integer[2, 3] = [[1, 2, 3], [4, 5, 6]];
Arr7: array[3, 3, 3] Of integer =
[[[1, 1, 1], [1, 1, 2], [1, 1, 3]],
[[2, 1, 1], [2, 2, 2], [2, 2, 3]],
[[3, 1, 1], [3, 2, 2], [3, 3, 3]]];
Begin
End Sub;
See also: