在 FormCreate 事件中加入
procedure TForm1.FormCreate(Sender: TObject);
var
a: array of String; // 動態字串陣列
i: Integer;
s: string;
begin
SetLength(a, 3); // a[0..2]
for i := Low(a) to High(a) do
begin
a[i] := IntToStr(i);
end;
s := '';
for i := Low(a) to High(a) do
begin
s := s + ',' + QuotedStr(a[i]);
end;
s[1] := '[';
s := s + ']';
with Memo1.Lines do
begin
Clear;
Add(s);
Add('Length: ' + IntToStr(Length(a)));
SetLength(a, 0); // Clear
Add('Length: ' + IntToStr(Length(a)));
end;
end;
沒有留言:
張貼留言