Use a char to control the switch : Switch : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Switch »

 

Use a char to control the switch









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Use a char to control the switch. 
 
using System; 
 
public class SwitchDemo2 {   
  public static void Main() { 
    char ch; 
 
    for(ch='A'; ch<= 'E'; ch++) 
      switch(ch) { 
        case 'A':  
          Console.WriteLine("ch is A"); 
          break; 
        case 'B':  
          Console.WriteLine("ch is B"); 
          break; 
        case 'C':  
          Console.WriteLine("ch is C"); 
          break; 
        case 'D':  
          Console.WriteLine("ch is D"); 
          break; 
        case 'E':  
          Console.WriteLine("ch is E"); 
          break; 
      }     
  }   
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Switch