Returns
one of two expressions depending on a condition.
Syntax
test
? expression1 : expression2
Returns
expression1 if the “test” condition evaluates to true other wise returns
expression2.
using System; class Program { static void Main(string[] args) { int a = 100; bool flag = a > 10 ? true : false; Console.WriteLine("flag = {0}", flag); } }
Output
flag
= True
No comments:
Post a Comment