Retrieve a MethodInfo on an int
-
22-09-2019 - |
Question
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!
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow