Conditional Operator in c#

Madhu.b.rokkam
Posted by Madhu.b.rokkam under C# category on | Points: 40 | Views : 2343
static void Main(string[] args)
{
bool condition = true;
int result = condition ? 13 : 14;
Console.WriteLine("Result is {0}", result);

//you can also embed the condition in other statements
Console.WriteLine("Condition is {0}", condition ? "TRUE" : "FALSE");

Console.Read();
}


output
Result is 13
Condition is TRUE

Comments or Responses

Login to post response