+ 1
Ternary operator
How it’s works?
2 ответов
+ 4
It is a short of if else statement
if (true)
//print a
else
//print b
true ? a : b;
0
Some other example for it.
Console.WriteLine(Console.ReadLine().Contains('a')? "No 'a'!" : "Good Input!");
Or
Console.WriteLine("Give in the Last value to complete the calculation: x + 2 = 4");
var sum = Convert.ToInt32(Console.ReadLine())+2==4? "Correct!": "Wrong!";