LANGUAGE

Conditional operator ?:

Selects one of two result expressions from a Boolean condition. The unselected expression is not evaluated.

Formal Syntax & Structure

csharp syntaxcsharp
condition ? whenTrue : whenFalse

Working Example

Example Snippetcsharp
string message = 3 > 0 ? "Ready" : "Empty";
C# & .NET Reference