Is it possible to call value type operators via reflection?

前端 未结 5 1417
别跟我提以往
别跟我提以往 2020-12-09 04:54

As C# operators e.g. +, +=, == are overridable. It lets me think they are sort of methods, thus wonder if there is a way to call them using reflection, on Int32 for instance

5条回答
  •  被撕碎了的回忆
    2020-12-09 05:44

    Yes, the custom operators are invokable using reflection (they have special names, such as op_Addition), but System.Int32 doesn't define them, as fundamental, built-in, types are handled directly by IL opcodes like add, rather than method calls.

提交回复
热议问题