Answers for "c# if"

C#
18

c# else if

string emotions;
emotions = Console.ReadLine();
//for emotions say the user input was either
//happy,sad and mad
if (emotions == "happy")
{
  Console.Write("You are happy");
}
else if (emotions == "sad")
{
    Console.Write("You are sad");
}
else if (emotions == "mad")
{
    Console.Write("You are mad");
}
else
{
    Console.Write("Unknown input");
}
Posted by: Guest on February-16-2020
1

c# if

int x;
int y;

if ( x == y)
	{
  		Console.WriteLine("x and y is equal");
	}
else
	{
  		Console.WriteLine("x and y is not equal");
	}

// Same, but shorter ( and harder XD )
Console.WriteLine($"x and y {(x == y? "is equal" : "is not equal")}");
Posted by: Guest on March-27-2021
3

if statement c#

if (condition)
{
  print("Yes");
}
else
{
  print("No");
}
Posted by: Guest on July-14-2020
0

c# if

if (condition1)
{
  // block of code to be executed if condition1 is True
} 
else if (condition2) 
{
  // block of code to be executed if the condition1 is false and condition2 is True
} 
else
{
  // block of code to be executed if the condition1 is false and condition2 is False
}
Posted by: Guest on May-31-2021
1

different types of if statements in c#

//Default If condition
                if (comEnvList.Items.Count > 0)
                {
                    comEnvList.SelectedIndex = 1;
                }
                else
                {
                    comEnvList.SelectedIndex = 0;
                }
                //IIf statement
                comEnvList.SelectedIndex = comEnvList.Items.Count > 0 ? 1 : 0;
Posted by: Guest on June-21-2020
0

c# if

if (20 > 18) 
{
  Console.WriteLine("20 is greater than 18");
}

/*
Less than: a < b
Less than or equal to: a <= b
Greater than: a > b
Greater than or equal to: a >= b
Equal to a == b
Not Equal to: a != b
*/
Posted by: Guest on July-01-2021

C# Answers by Framework

Browse Popular Code Answers by Language