Delphi TList of records

后端 未结 8 997
遥遥无期
遥遥无期 2020-12-13 02:55

I need to store a temporary list of records and was thinking that a TList would be a good way to do this? However I am unsure how to do this with a TList<

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 03:18

    Use Generiс TList from System.Generics.Collections. If you need to access to a record in generic TList by-reference and do not copy record: use List.List - direct access to the array of TList.

    MyList := TList.Create; 
    [...] 
    
    var lRecP: PTestRec; // (PTestRec = ^TTestRec)
    lRecP := @MyList.List[i]; 
    

    Now you can access to record inside Tlist array without copying it.

提交回复
热议问题