如何修改TList< record>值? [英] How to modify TList<record> value?

查看:98
本文介绍了如何修改TList< record>值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Delphi 2010
如何修改TList<记录>值?

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


推荐答案

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.

这篇关于如何修改TList&lt; record&gt;值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆