Switch Statement
using System;
/*The switch statement chooses flow of control based on the evaluation of a numeric or string comparison.
It is used for comparing one expression with more than one values.*/
class TestSwitch
{
static void Main(string[] args)
{
int i = 3;
switch (i)
{
case 1: Console.WriteLine("Value is 1");
break; // Break is used to exit from case block
case 2: Console.WriteLine("Value is 2");
break;
case 3: Console.WriteLine("Value is 3");
break;
case 4: Console.WriteLine("Value is 4");
break;
case 5: Console.WriteLine("Value is 5");
break;
}
Console.ReadLine();
}
}
Output:
Value is 3