The conditional operator is a miniature if statement that can be embedded inside a larger expression. Its syntax is:

    condition ? true-result : false-result

The condition is a Boolean expression. The values true-result and false-result must be of the same data type. If the condition's result is true then the result of the conditional operator is true-result and false-result is not evaluated. If the condition's result is false then the result of the conditional operator is false-result and true-result is not evaluated. If the condition's result is null then the result of the conditional operator is null and neither true-result nor false-result is evaluated. For an example of how a conditional operator may be used, refer to the example at the end of the Casting Operators page.