如何根据属性名称给属性赋值?

ShallowShrimp ShallowShrimp 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
请教各位高手,我自己创建一个类:
TWorker = class(TObject)
private
FsWorkerName:string;
public
published
property sWorkerName:string read FsWorkerName write FsWorkerName;
end;

引用下面语句赋值:
var NewWorker:TWorker;
begin
NewWorker:=TWorker.Create;
SetPropValue(NewWorker,'sWorkerName','shallowshrimp');
end;

结果系统报错,为什么?
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EPropertyError with message 'Property sWorkerName does not exist'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
ShallowShrimp
Delphi 5,944 成员 262,941 内容