Demonstrate an enumeration : Enum : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » Enum »

 

Demonstrate an enumeration









    

 
using System; 
 
public class EnumDemo { 
  enum apple { Jonathan, GoldenDel, RedDel, Winsap, 
               Cortland, McIntosh }; 
 
  public static void Main() { 
    string[] color = { 
      "Red", 
      "Yellow", 
      "Red", 
      "Red", 
      "Red", 
      "Redish Green" 
    }; 
 
    apple i; 
 
    for(i = apple.Jonathan; i <= apple.McIntosh; i++)  
      Console.WriteLine(i + " has value of " + (int)i); 
 
    Console.WriteLine(); 
 
    for(i = apple.Jonathan; i <= apple.McIntosh; i++)  
      Console.WriteLine("Color of " + i + " is " + 
                         color[(int)i]); 
 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» Enum