This program will help beginners to learn the conditional operator provided by C#. if condition is true it will give before : (colon) results otherwise give after :(colon) results.
C# Code Example for Conditional Operator:
using System;
namespace MyApp
{
class conditional_class
{
static void Main()
{
bool my_bool = true;
string strResult = my_bool ? "True condition" : "False condition";
Console.WriteLine("{0}", strResult);
Console.WriteLine("Condition is {0}", my_bool ? "The condition is true" : "The condition is false");
Console.Read();
}
}
}
No comments:
Post a Comment