d 属性: 赋予字段执行动作的能力

1、对只读属性误解

property AppSetting: ISuperobject read fAppSetting;
当看到
AppInfo.AppSetting.D['lastLat'] := FLastLat;
AppInfo.AppSetting.I['lastZoom'] := FLastZoom;
时,惊讶只读属性的AppSetting怎么可以写操作呢?
原来整个 AppSetting 不可以写,但是里面的细项是可以操作的,不可以整个赋值而已。

 

 

2、属性数组 也可以多个参数的
function GetPurviewVisible(const GUID_Addr: string; const GUID_Mapping: string): boolean;
property Visible[const GUID_Addr: string; const GUID_Mapping: string]: boolean read GetPurviewVisible;
注:这个相当于是直接调用函数, 其实属性的作用?

他本身就是一个变量,
自己定义了get和set方法,
如果楼主想取得这个值的时候,程序执行的时候,自动的调用get方法,GET方法最后将这个值做为result返回。。。
如果要更改这个值的时候,会调用set方法,,,value就是我们 :=更改值
做为参数传给set方法,然后调用set方法进行操作。。

如果是只写属性,还不如直接用方法;

 

posted @ 2016-10-28 11:56  海蓝7  阅读(175)  评论(0编辑  收藏  举报