Once thought, Delphi should be able to give the array to assign value is good: arr: = [...]; Vararrayof is not a new thing, but I haven't used it before.
var
bs:tbytes;
bs:tarray<byte>begin//SetLength (BS, 3);
BS: = vararrayof ([One, All,]);
ShowMessage (IntToStr (bs[2)); 33end;
var
strarr:tarray<string>
begin//setlength (Strarr, 3);
Strarr: = vararrayof ([' AAA ', ' BBB ', ' CCC '
]);
ShowMessage (strarr[2]); Cccend;
This is only used for dynamic arrays, and even for generic writing, but not for static arrays; However, as a function parameter, only the traditional dynamic array is supported.
function getsum (aarr:arrayof integer): integer;
var
i:integer;
Begin result
: = 0;
For I-Aarr do Inc. (result, i);
End;
Procedure Tform1.formcreate (sender:tobject);
var
n:integer;
Begin
N: = Getsum ([1, 2, 3]);
ShowMessage (IntToStr (n)); 6
N: = Getsum ([1, 2, 3, 4, 5, 6, 7, 8, 9, ten]);
ShowMessage (IntToStr (n)); 55end;
There is also a GDI + in the very good function was neglected, now only know its good: this is GDI + in the Bitmap pixels[] properties, and canvas.pixels[] different, it faster!