首页 > 代码库 > 循环 枚举 Enum 名称与值

循环 枚举 Enum 名称与值

 
foreach (WeekDay c in (WeekDay [])Enum.GetValues(typeof(WeekDay )))

{
Console.Write(String.Format("{0}是一周第{1}天",c.ToString(),(int)c));
}

 

 

 

Hashtable Ht = new Hashtable();
        Ht.Add("January", "1月");
        Ht.Add("February", "2月");
        Ht.Add("March", "3月");
        Ht.Add("April", "4月");
        Ht.Add("May", "5月");
        Ht.Add("June", "6月");
        Ht.Add("July", "7月");
        this.DropDownList3.DataSource = Ht;
        this.DropDownList3.DataValueField = "key";
        this.DropDownList3.DataTextField = "value";
        this.DropDownList3.DataBind();

循环 枚举 Enum 名称与值