Kindly find an example of using Ternary Operator.
//With out ternary operator
int Number = 10;
bool IsNumber;
if (Number == 11)
{
IsNumber = true;
}
else
{
IsNumber = false;
}
Console.WriteLine("Number == 10 is {0}", IsNumber);
Console.Read();
//With ternary Operator
int Number = 10;
bool IsNumber = Number == 11 ? true : false;
Console.WriteLine("Number == 10 is {0}", IsNumber);
Console.Read();
//With out ternary operator
int Number = 10;
bool IsNumber;
if (Number == 11)
{
IsNumber = true;
}
else
{
IsNumber = false;
}
Console.WriteLine("Number == 10 is {0}", IsNumber);
Console.Read();
//With ternary Operator
int Number = 10;
bool IsNumber = Number == 11 ? true : false;
Console.WriteLine("Number == 10 is {0}", IsNumber);
Console.Read();
No comments:
Post a Comment