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.

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.