Search code examples
c#operator-overloadingint32

How does Int32 overloads operators?


I quickly go through Int32 struct definition, and I do not find any overload to operators like + - * /, but for String class, we can directly find them. How does Int32 implement such feature?


Solution

  • They are baked into the CLR, and are not part of the code outputted as Reference Source. Hence you can't find them.

    For String, only two operators are visible: those written in C#. Those in the CLR are also not shown (like the + operator).