枚举的遍历和字符串转枚举,枚举转字符串 转

  enum   Score
  {  
  EE,EX,BE,ME,PME
  }  

枚举的遍历
  foreach(   Scorecity   in   enum.getvalues(   typeof(   Score)   )   )   
{

}    

字符串转枚举

Score enumtype;  
  string   strTypeB   =   "EE";  
  enumtype   =   (Score)Enum.Parse(typeof(Score),strTypeB);   
   
枚举转字符串

myScore     enumtype = Score.EE;

string strTypeB = Enum.GetName(typeof(myScore ), enumtype);

posted on 2010-03-18 11:03  沸石  阅读(338)  评论(0编辑  收藏  举报

导航