8.12 The Conditional Operator
The conditional operator (?:) returns one of two values depending on a third value. The operator is used in an expression of the following form:
expr1 ? expr2 :expr3
This expression is equivalent to the following:
If (expr1) {
expr2;
} else {
expr3;
}
expr1 must evaluate to a bool. Unlike C and C++, in C# expr1 cannot evaluate to an int and expect the runtime to interpret a value of 1 as true and 0 as false.
 |