如何在Delphi中给setter第二个参数?
我想知道我们是否可以在Delphi中这样做: 我有一个私有过程:
procedure SetMySend(const oValue: TTM_MySend_Profile;
displayValue: string = '...');
我有一个公共属性:
property MySend: TTM_MySend_Profile displayLocateID '...'
read FMySend write SetMySend;
我可以在这里给出一个参数 displayValue 作为设置器的第二个参数吗?我无法编译这个。
我无法找出正确的方法来做到这一点,并且想知道我是否可以在 Delphi 中做到这一点。感谢您的帮助!
I want to know whether we can do such in Delphi:
I have a private procedure:
procedure SetMySend(const oValue: TTM_MySend_Profile;
displayValue: string = '...');
I have a public property:
property MySend: TTM_MySend_Profile displayLocateID '...'
read FMySend write SetMySend;
Can I give a parameter displayValue here as the 2nd parameter of the setter? I cannot get this compiled.
I cannot figure out the correct way to do it and wonder whether I can do this in Delphi. Thanks for help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
属性的属性设置器仅采用一个与该属性类型相同的参数。没有任何语法允许您编写您尝试编写的代码类型。请注意,我忽略了与此处不相关的数组属性。
您需要做的是编写一个专用的 setter,为您的
SetMySend
函数提供额外的参数。然后在您编写的实现中
您可以劫持 索引说明符 来实现类似的效果,但我不建议这样做。
A property setter for a property takes only one parameter, of the same type as the property. There is no syntax that would allow you to write the type of code you are attempting to write. Note that I am ignoring array properties which are not pertinent here.
What you need to do is to write a dedicated setter which supplies the extra parameter to your
SetMySend
function.And then in the implementation you write
You could hijack index specifiers to effect something similar, but I would not recommend that.