Determining the Type of an Expression

Several examples were presented in the previous chapter of how the many simple types found in C# impose a complicated life for the compiler. We saw how the C# compiler attempts to handle the often tricky situations of assignment statements by performing implicit conversions, and how the programmer can interfere by using explicit conversions in the form of type casts.

In this section, we will look at how operators affect the type of the value returned from a numerical expression. This will enable you to determine the type of expressions, such as

which mixes together two types. Because any expression only has ...

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.