delphi property read writer 如何使用
type
TMyClass = class(TObject)
private
FMyName: string;
FMyAge: Integer;
procedure SetAge(age: Integer);
function GetAge(): Integer;
published
property MyName: string read FMyName write FMyName;
property MyAge: Integer read GetAge write SetAge;
end; procedure TMyClass.SetAge(age: Integer);
begin
if (age < 0) or (age > 200) then
ShowMessage('当前设置的年龄数值: ' + IntToStr(age) + '不是有效的年龄数值')
else FMyAge := age;
end; function TmyClass.GetAge: Integer;
begin
Result := FMyAge;
end; // 测试
procedure TForm1.Button1Click(Sender: TObject);
var
ta: TMyClass;
begin
ta := TMyClass.Create;
ShowMessage('myname:' + ta.MyName + ', myage:' + IntToStr(ta.MyAge));
ta.MyName := 'Tom';
ta.MyAge := -10;
ShowMessage('myname:' + ta.MyName + ', myage:' + IntToStr(ta.MyAge));
ta.MyAge := 22;
ShowMessage('myname:' + ta.MyName + ', myage:' + IntToStr(ta.MyAge));
ta.free;
end;
delphi property read writer 如何使用的更多相关文章
- Delphi Property详解
http://anony3721.blog.163.com/blog/static/51197420107105132120/?ignoreua Property Keyword Defines co ...
- Hadoop入门进阶课程13--Chukwa介绍与安装部署
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,博主为石山园,博客地址为 http://www.cnblogs.com/shishanyuan ...
- 分布式日志收集系统--Chukwa
1. 安装部署 1.1 环境要求 1.使用的JDK的版本必须是1.6或者更高版本,本实例中使用的是JDK1.6 2.使用的hadoop的版本必须是Hadoop0.20.205.1及以上版本,本实例中使 ...
- 007.Compiled
Delphi property Compiled: Boolean read FCompiled; 类型:property 可见性:public 所在单元:System.RegularExpressi ...
- json.net 比jsonIgnore 更好的方法 修改源码
关于 JsonIgnore 问题, EF T4 模板 中 存在主外键关系 namespace WindowsFormsApplication1{ using System; using ...
- c++builder XE7 C++11 C++0x 新语法
Non-static data member initializers 非静态成员变量初始化变得简单,这个XE7 64位编译成功,32位还是不支持 As a simple example, struc ...
- Delphi的属性Property
参考:http://www.cnblogs.com/edisonfeng/archive/2012/05/22/2513727.html 一.基本属性 TOnUserInfoShow = proced ...
- NativeXml: A native Delphi XML parser and writer
http://www.simdesign.nl/xml.html This software component contains a small-footprint Object Pascal (D ...
- Delphi资源大全
A curated list of awesome Delphi frameworks, libraries, resources, and shiny things. Inspired by awe ...
随机推荐
- gitlab分支代码本地拉取及jenkins关联gitlab分支
git本地拉取 git init git remote add origin http://47.*.*.*:8089/back_dev/claimeureka.git git fetch origi ...
- git排错
解决: 将远程仓库中除.git以外的所有文件删除,然后执行 git config --bool core.bare true 然后客户端重新push即可解决问题 还要注意远程仓库权限方面...
- STL语法——集合:set 安迪的第一个字典(Andy's First Dictionary,UVa 10815)
Description Andy, , has a dream - he wants to produce his very own dictionary. This is not an easy t ...
- SkylineGlobe Android 开发 面积计算示例代码
SkylineGlobe Android 开发 面积计算示例代码: 如果之前熟悉SkylineGlobe桌面端的二次开发,看这些代码应该不难理解. package com.skyline.terrae ...
- java計算年齡的工具類
整理一篇Java計算年齡的工具類,方便實用 public static int getAgeByBirth(String birthday) throws ParseException { // 格式 ...
- Luogu3209 HNOI2010 平面图判定 平面图、并查集
传送门 题意:$T$组数据,每组数据给出一个$N$个点,$M$条边,并存在一个$N$元环的图,试判断其是否为一个可平面图(如果存在一种画法,使得该图与给出的图同构且边除了在顶点处以外互相不相交,则称其 ...
- VS2017中 C# dll引用(C生成dll,C++生成dll)小结 - 简书
原文:VS2017中 C# dll引用(C生成dll,C++生成dll)小结 - 简书 dll引用小结 一.dll与应用程序 动态链接库(也称为DLL,即为“Dynamic Link Library” ...
- ionic访问odoo 11接口
在架设完毕odoo 11的网站之后,第一次面临手机app该如何访问后台网站的问题,是不是模式类似asp.net mvc 那样的模式,或者还存在其他的访问方法,带着这个疑问与困惑,开始的我的研究学习之路 ...
- Luogu P3398 仓鼠找sugar
这还是一道比较好的树剖题(去你的树剖,LCA即可) 这里主要讲两种思路,其实都是很基本也很经典的 1 树链剖分 还是先讲一下这种算法吧,虽然写起来很烦(不过感觉写多了就习惯了,而且还有一种莫名的快感) ...
- 理解标准盒模型和怪异模式&box-sizing属性
盒子模型 主要有两种,w3c标准盒模型,IE下的怪异盒模型,其实还有就是弹性盒模型(上篇文章我们用他很好的解决了对齐问题) DTD规范 盒模型分为:标准w3c盒模型.IE盒模型.以及css中的伸缩盒模 ...