Under the Hood
The conditional operator is implemented using branching similar to the
if statement. The code shown in Figure 5.24 is the result of an optimized Release build because the Debug code is a bit more involved with temporary compiler-generated variables. Yes, that’s right. The C# compiler knows to optimize code to some extent.
Note: A Word on Optimization
People sometimes freak out when IL code doesn’t look as optimized as they expect it to. The general approach taken by managed code compilers it to limit optimizations and leave some of the potential further optimizations to the ...