Combining Different Types in One Expression

Recall that even the most complicated expressions involving binary operators can be divided into sub-expressions, each consisting of two operands and an operator; and remember how operator precedence and associativity rules determine to which operand each operator is applied. Along with the values passed through the various levels of this sub-expression hierarchy are also the types of these values, as illustrated in Figure 7.3.

Figure 7.3. Types from sub-expressions transferred through expression hierarchy.

Consequently, if we can somehow determine the type of any expression involving just two operands ...

Get C# Primer Plus 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.