Using way multi TList in Delphi XE5 -
i want use multi tlist in delphi. example:
var temp1list : tlist; temp2list : tlist; begin temp1list := tlist.create; temp2list := tlist.create; temp1list.add(temp2list); end; i think not correct because tlist accepts parameter pointer value.
is there way use multi tlist?
have @ generic tlist<t> instead, eg:
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 free them when done... temp1list.free; temp2list.free; end; alternatively, since tlist class type, can use tobjectlist<t> instead, , take advantage of ownsobjects feature:
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 default temp2list := system.classes.tlist.create; temp1list.add(temp2list); // don't forget free them when done... temp1list.free; // free temp2list end;
Comments
Post a Comment