检索 int 上的 MethodInfo

发布于 2024-08-19 00:10:55 字数 190 浏览 7 评论 0原文

是否可以在 Int32 上检索 * 运算符的 MethodInfo?

我已经尝试过这段代码但没有成功(它返回 null):

MethodInfo mi = typeof(System.Int32).GetMethod("op_Multiply");

谢谢!

Is it possible to retrieve the MethodInfo for * operator on an Int32?

I've tried this code but without success (it returns null):

MethodInfo mi = typeof(System.Int32).GetMethod("op_Multiply");

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相权↑美人 2024-08-26 00:10:55

不,这是不可能的——不存在这样的方法。

基本类型(Decimal 除外)的算术作为 IL 指令(muladddiv 等)实现,而不是方法。
您可以在此处查看 IL 操作码的完整列表。

No, it's not possible - no such method exists.

Arithmetic on primitive types (except Decimal) is implemented as IL instructions (mul, add, div, etc), not methods.
You can see the complete list of IL opcodes here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文