The switch statement with a user input from keyboard : Switch : Statement C# Examples


C# Examples » Statement » Switch »

 

The switch statement with a user input from keyboard









    
using  System;


public  class  MainClass  {
        public  static  void  Main(  )  {
                Console.WriteLine("Please  make  your  selection");
            Console.WriteLine("1  Hamburger");
            Console.WriteLine("2  Cheese  Burger");
            Console.WriteLine("3  Fish");

            int  Selection  =  int.Parse(  Console.ReadLine(  )  );

            switch(  Selection  )  {

                case  1:
                    Console.WriteLine("Hamburger");
                    break;
        
                case  2:
                    Console.WriteLine("Cheese  Burger");
                    break;
        
                case  3:
                    Console.WriteLine("Fish");
                    break;
        
                default:
                    Console.WriteLine("Unknown  choice");
                    break;
            }
        }
}
    
   
  
   



Output

Please make your selection
1 Hamburger
2 Cheese Burger
3 Fish
1
Hamburger


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» Switch