用动态数组TMyClass=class(TObject) private FData:array of Word; function GetData(const index:integer):Word; procedure AddData(d:Word):Word; public property Data[const index:integer]:Word read GetData; end;function TMyClass.GetData(const index:integer):Word; begin Result:=0; if index<Length(FData) then begin Result:=FData[index]; end; end;procedure TMyClass.AddData(d:Word):Word; begin SetLength(FData,Length(FData)+1); FData[Length(FData)]:=d; end;以上代码只是告诉你方法。如果你愿意,还可以加property DataCount等属性 方便操作
private
FData:array of Word;
function GetData(const index:integer):Word;
procedure AddData(d:Word):Word;
public
property Data[const index:integer]:Word read GetData;
end;function TMyClass.GetData(const index:integer):Word;
begin
Result:=0;
if index<Length(FData) then begin
Result:=FData[index];
end;
end;procedure TMyClass.AddData(d:Word):Word;
begin
SetLength(FData,Length(FData)+1);
FData[Length(FData)]:=d;
end;以上代码只是告诉你方法。如果你愿意,还可以加property DataCount等属性
方便操作