I liked this operator. It is called "ternary" operator too.
I can use it instead of basic "if" statements.
And the code sample:
Syntax of this:
condition ? consequent : alternative
1 2 3 4 5 6 7 8 9 10 | using System; class Operators { static void Main() {start: //a label to start again Console.Write("Do you want to continue? (y, n): "); string answer = Console.ReadLine(); Console.WriteLine(answer == "y" ? "Congrats!" : "See you later!"); goto start; } } |
Comments
Post a Comment