Empty cases can fall through : Switch : Statement C# Examples


C# Examples » Statement » Switch »

 

Empty cases can fall through









    
using  System;  
  
class  MainClass  {      
    public  static  void  Main()  {  
        int  i;  
  
        for(i=1;  i  <  5;  i++)    
            switch(i)  {  
                case  1:  
                case  2:  
                case  3:  Console.WriteLine("i  is  1,  2  or  3");  
                    break;  
                case  4:  Console.WriteLine("i  is  4");  
                    break;  
            }  
  
    }  
}
    
   
  
   



Output

i is 1, 2 or 3
i is 1, 2 or 3
i is 1, 2 or 3
i is 4


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» Switch