Loop through the enum data type : Enum : Data Type C# Examples


C# Examples » Data Type » Enum »

 

Loop through the enum data type









    
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(i  +  "  has  value  of  "  +  (int)i);  
  
    }  
}
    
   
  
   



Output

Monday has value of 0
Tuesday has value of 1
Wednesday has value of 2
Thursday has value of 3
Friday has value of 4
Saturaday has value of 5
Sunday has value of 6


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Enum