如何从 MethodInfo 创建 Action 委托?
我想从 MethodInfo 对象获取操作委托。这可能吗?
I want to get an action delegate from a MethodInfo object. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我想从 MethodInfo 对象获取操作委托。这可能吗?
I want to get an action delegate from a MethodInfo object. Is this possible?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
使用Delegate.CreateDelegate:
对于
操作< /code> 等,只需在各处指定适当的委托类型即可。
在 .NET Core 中,
Delegate.CreateDelegate
不存在,但MethodInfo.CreateDelegate
存在:Use Delegate.CreateDelegate:
For an
Action<T>
etc, just specify the appropriate delegate type everywhere.In .NET Core,
Delegate.CreateDelegate
doesn't exist, butMethodInfo.CreateDelegate
does:这似乎也适用于约翰的建议:
This seems to work on top of John's advice too: