How to use if-else statement in C#?

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();
        }
    }
}

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.