Empty cases can fall through : Switch : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Switch »

 

Empty cases can fall through









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Empty cases can fall through. 
 
using System; 
 
public class EmptyCasesCanFall {   
  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; 
      } 
 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Switch