How to modify TList value?

前端 未结 4 742
醉酒成梦
醉酒成梦 2020-12-16 17:33

Delphi 2010 How to modify TList < record > value ?

type TTest = record a,b,c:Integer end;
var List:TList;
    A:TTest;
    P:Pointer;
....
..         


        
4条回答
  •  独厮守ぢ
    2020-12-16 17:45

    If you need to manipulate objects in that form, it is better to use TObjectList instead of TList, and define the structure as a class rather than a record:

    type TTest = class a,b,c:Integer end;
    var List:TObjectList;
        A:TTest; // A is an object so there's no need for a pointer
    ....
    ....
    List.Add(TTest.Create);
    List.Last.a := 1;
    A:=List.Last;
    

提交回复
热议问题