Below code shows how to use if-else statement in csharp/c# –
using System;
namespace kodehelp.csharp.basic
{
class IfElseStatement
{
public static void Main(string[] args)
{
int a = 1;
int b = 2;
//
// A simple if-else block
//
if (a < b)
{
Console.WriteLine("you passed if statement");
}
else if (a==b)
{
Console.WriteLine("you passed else-if statement");
}else{
Console.WriteLine("you passed else statement");
}
Console.ReadLine();
}
}
}