Search code examples
c#reflectionmethodinfo

Retrieve a MethodInfo on an int


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.