看一看通用TList<T>
代替,例如:
uses
..., System.Classes, System.Generics.Collections;
var
temp1List : System.Generics.Collections.TList<System.Classes.TList>;
temp2List : System.Classes.TList;
begin
temp1List := System.Generics.Collections.TList<System.Classes.TList>.Create;
temp2List := System.Classes.TList.Create;
temp1List.Add(temp2List);
// don't forget to free them when you are done...
temp1List.Free;
temp2List.Free;
end;
另外,由于TList
是类类型,你可以使用TObjectList<T>
代替,并采取了OwnsObjects
功能的优势:
uses
..., System.Classes, System.Generics.Collections;
var
temp1List : System.Generics.Collections.TObjectList<System.Classes.TList>;
temp2List : System.Classes.TList;
begin
temp1List := System.Generics.Collections.TObjectList<System.Classes.TList>.Create; // takes Ownership by default
temp2List := System.Classes.TList.Create;
temp1List.Add(temp2List);
// don't forget to free them when you are done...
temp1List.Free; // will free temp2List for you
end;
我应该学习通用部分..谢谢你申请! –