使用下面的结构,我如何定义我的 TAnimalCollection 类来存储我的收藏?调用 SelectAll 或 SelectTop10 将更新 SelectedRecords。删除私有字段允许代码编译,但没有机制来存储返回的结果集。
TDog = class
private
FBreed: string;
public
property Breed: string read FBreed write FBreed;
end;
TCat = class
private
IsWild: string;
public
property IsWild: string read FIsWild write FIsWild;
end;
TMyArray<T> = array of T;
TAnimalCollection = class
private
SelectedRecords: TMyArray<T>; // Generates: Undeclared Identifier: 'T'
public
function SelectAll<T>: TMyArray<T>;
function SelectTop10<T>: TMyArray<T>;
// Other Methods
end;