Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Delphi 2010 How to modify TList < record > value ?

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

List[10] := A;  <- OK
List[10].a:=1;  <- Here compiler error : Left side cannot be assined to
P:=@List[10];   <- Error: Variable requied
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

A := List[10];
A.a := 1;
list[10] := A;

You don't have to do this with objects because they're reference types, (accessed through a pointer which the compiler manages internally to keep it out of your hair,) but records are value types so it doesn't work that way.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...