如何将“Button b3 = (Button)sender”转换为“Button b3 = (Button)sender”从 C# 到 IronPython
我想将 C# 语句转换
Button b3 = (Button)sender;
为ironpython 语句
I want to convert C# statement
Button b3 = (Button)sender;
to ironpython statement
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设 sender 被键入为对象(换句话说,没有用户定义的转换运算符),您可以像 C# 代码中的 b3 一样使用 sender。 完全相同的代码为:
b3 = sender
C# 只需要执行此操作,因为它想要静态类型化对象。如果您不是将 Button 转换为显式实现的对象的接口,那么它会变得更加复杂。
Assuming sender is typed to object (in other words there are no user defined conversion operators) you can just use sender like you would b3 in the C# code. The exact same code would be:
b3 = sender
C# only needs to do this because it wants to statically type objects. If instead of Button you were casting to an interface for an object where it's explicitly implemented it gets more complicated.
b3 = 发送者.Content()
b3 = sender.Content()