Handle two switch cases : Switch : Statement C# Examples


C# Examples » Statement » Switch »

 

Handle two switch cases









    
using  System;

class  MainClass
{
        public  static  void  Main()
        {
                int  i  =  1;
                
                switch  (i)
                {
                        case  1:
                        case  2:
                        //  code  here  handles  both  1  and  2
                        Console.WriteLine("Low  Number");
                        break;
                        
                        case  3:
                        Console.WriteLine("3");
                        goto  case  4;
                        
                        case  4:
                        Console.WriteLine("Middle  Number");
                        break;
                        
                        default:
                        Console.WriteLine("Default  Number");
                        break;
                }
        }
}
    
   
  
   



Output

Low Number


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» Switch