(论坛答疑点滴)遍历枚举

using  System;  
 
public  class  EnumTest  {  
       
enum  Days  {  Saturday,  Sunday,  Monday,  Tuesday,  Wednesday,  Thursday,  Friday  };  
 
       
public  static  void  Main()  {  
 
               Type  weekdays  
=  typeof(Days);  
 
               Console.WriteLine(
"The  days  of  the  week,  and  their  corresponding  values  in  the  Days  Enum  are:");  
 
               
foreach  (  string  s  in  Enum.GetNames(weekdays)  )  
                       Console.WriteLine(  
"{0,-11}=  {1}",  s,  Enum.Format(  weekdays,  Enum.Parse(weekdays,  s),  "d"));  
       }  
}  
posted @ 2006-01-19 11:26  lovecherry  阅读(2976)  评论(5编辑  收藏  举报