Operator Overloading Internals

Internally, Microsoft Intermediate Language (MSIL) does not support operator methods. For that reason, the C# compiler converts operator methods into normal functions. Figure 9-2 presents a view of the Summation class discussed in the previous section. Instead of operator methods, there are functions such as op_Addition and op_Explicit.

A view of the Summation class

Figure 9-2. A view of the Summation class

In Table 9-1, the functions that the C# compiler substitutes for mathematical and logical operators are listed.

Table 9-1. Replacement methods for mathematical and logical operators

Operator

Replacement method

operator+

op_Addition

operator-

op_Subtraction ...

Get Programming Microsoft® Visual C#® 2008: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.