Arrays Delphi examples
提示:动态数组演示
核心源码
procedure TForm1.Button1Click(Sender: TObject);
type
TMyRecord = record
Field1: string;
Field2: string;
Field3: integer;
end;
var
i: integer;
MyRecord: array of TMyRecord;
begin
// Clear the memo content
Memo1.Clear;
// Set the length for the dynamic array
SetLength(MyRecord, 200);
// Set field values
for i := 0 to High(MyRecord) do
begin
MyRecord[i].Field1 := 'MyField1 ’ + IntToStr(Random(200));
MyRecord[i].Field2 := 'MyField2 ’ + IntToStr(Random(200));
MyRecord[i].Field3 := Random(200);
end;
// Print all
for i := 0 to High(MyRecord) do
be