O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Associativity

A relatively minor remark to conclude the discussion of the conditional operator is its right-associative behavior:

condition1 ? a : condition2 ? c : d

The preceding means the same as the following:

condition1 ? a : (condition2 ? c : d)

However, nested conditional operators tend to produce unreadable code quickly (partly due to the terse ?: syntax), so I generally recommend avoiding such use.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required