+ 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