看看下面的单元,是你要的动态数组的副职的:
unit Unit1;
interface
uses
// The System unit does not need to be defined
SysUtils,
Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm} // Include form definitions
procedure TForm1.FormCreate(Sender: TObject);
var
singleArray : array of string;
multiArray : array of array of Word;
i, j : Integer;
begin
// Set the length of a single dimension array
SetLength(singleArray, 4);
// Now fill it up : note that dynamic arrays start at 0
ShowMessage('Single dimensional array :');
for i := 0 to 3 do
begin
singleArray := 'String '+IntToStr(i);
ShowMessage('Element '+IntToStr(i)+' = '+singleArray);
end;
// Set the length of a multi dimensional array
SetLength(multiArray, 2, 3);
// Now fill it up
ShowMessage('Multi-dimensional array :');
for i := 0 to 1 do
for j := 0 to 2 do
begin
multiArray[i,j] := i + j;
ShowMessage('Element '+IntToStr(i)+','+IntToStr(j)+' = '+
IntToStr(multiArray[i,j]));
end;
end;
end.