Use an enumeration to index an array : Enum : Data Type C# Examples


C# Examples » Data Type » Enum »

 

Use an enumeration to index an array









    
using  System;  
  
class  MainClass  {  
    enum  Week  {  Monday,  Tuesday,  Wednesday,  Thursday,  Friday,  Saturaday,Sunday  };  
  
    public  static  void  Main()  {  
        Week  i;
  

        
        for(i  =  Week.Monday;  i  <=  Week.Sunday;  i++)    
            Console.WriteLine("Color  of  "  +  i  +  "  is  "+  (int)i);  
  
    }  
}
    
   
  
   



Output

Color of Monday is 0
Color of Tuesday is 1
Color of Wednesday is 2
Color of Thursday is 3
Color of Friday is 4
Color of Saturaday is 5
Color of Sunday is 6


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Enum