CopyTo(Arr: Array; Index: Integer);
Arr. Array, to which collection elements must be copied.
Index. Index of position in the array, from which elements are inserted.
The CopyTo method copies collection to the Arr array.
Elements are inserted starting from the Index position. The specified array must be initialized before. If size of the specified array is less than the number of collection elements, not all data is copied.
Sub UserProc;
Var
StrL: IStringList;
Arr: Array;
i: Integer;
v: Variant;
Begin
StrL := New StringList.Create;
For i := 0 To Math.RandBetweenI(0, 10) Do
StrL.Add(Char.Chr(Math.RandBetweenI(65, 90)));
End For;
Arr := New Variant[Strl.Count];
Strl.CopyTo(Arr, 0);
//View values in the obtained array
For Each v In Arr Do
Debug.WriteLine(v);
End For;
End Sub UserProc;
On executing the example all elements from the StrL string array are copied to the Arr array.
See also: