CSharp examples for Language Basics:Operator
The conditional operator has the following format:
Condition ? if_true_statement : if_false_statement;
class MainClass// ww w . j a v a2s . c om { static void Main() { int Val1 = 1; int Val2 = 0; int result; result = (Val1 == Val2) ? 1 : 0; System.Console.WriteLine("The result is {0}", result); } }