conditional statements in csharp code example
Example 1: if statement c#
if (condition)
{
print("Yes");
}
else
{
print("No");
}
Example 2: conditonal statements c sharp online
var rand = new Random();
var condition = rand.NextDouble() > 0.5;
var x = condition ? 12 : (int?)null;
Example 3: if c#
int time = 22;
if (time < 10)
{
Console.WriteLine("Good morning.");
}
else if (time < 20)
{
Console.WriteLine("Good day.");
}
else
{
Console.WriteLine("Good evening.");
}