SEARCH C# PROGRAMMING CODES HERE

if...else… if...else Statement

if...else… if...else Statement in C#
An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.
Example
using System;

namespace Function
{
    public class Program
    {
        /* Main function */
        static void Main(string[] args)
        {
  /* local variable definition */
     int x = 100;
 /* check the boolean condition */
       if (x == 80)
        {
/* if the condition is true then print the following */
   Console.WriteLine("Value of x is 80");
         }
   else if (x == 25)
         {
  /* if else if condition is true */
   Console.WriteLine("Value of x is 25");
         }
      else if (x== 15)
        {
  /* if else if condition is true  */
   Console.WriteLine("Value of x is 15");
        }
      else
        {
     /* if none of the conditions is true */
     Console.WriteLine("None of the values is matching.");
         }
     Console.WriteLine("Value of x is= {0}", x);
        Console.ReadLine();
        }
    }
}

Output -None of the values is matching.
             Value of x is=100