Answers for "using if else statement in c#"

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

using if else statement in c#

using System;
					
public class Program
{
	public static void Main()
	{
		
        int number = 89;
		if (number > 50) {
			Console.WriteLine("the number {0} is grater than 50",number );
		}
		else {
			Console.WriteLine("the number {0} is less than 50",number );
		}
	}
}
Posted by: Guest on October-30-2021
0

C# how to use if and else

string text = Console.ReadLine();
if(text == "yes")
{
    Console.WriteLine("Correct!");
}
else
{
    Console.WriteLine("Incorrect!");
}
Posted by: Guest on September-30-2021

C# Answers by Framework

Browse Popular Code Answers by Language