+ 1

Ternary operator

How it’s works?

7th Jul 2022, 1:47 PM
Никита Шабанов
Никита Шабанов - avatar
2 Answers
+ 4
It is a short of if else statement if (true) //print a else //print b true ? a : b;
7th Jul 2022, 1:50 PM
A͢J
A͢J - avatar
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!";
7th Jul 2022, 5:46 PM
Felix Alcor
Felix Alcor - avatar