Skip to content

What is ? in C#

The classic if .. else .. statement represented as:
if (x == 1)
{
   x = 2;
}
else
{
   x = 3;
}

can be condensed to:

x = (x==1) ? 2 : 3;

 
Tags: