C#枚举变量常用操作

1.获取枚举变量collection
public static Liststring GetPartNameCollection() { Liststring collection = new Liststring(); Type part = typeof(HTMLPART); foreach (string s in Enum.GetNames(part)) collection.Add(s); return collection; }

2.字符串转换成变量
Type part = typeof(HTMLPART); HTMLPART EnumPartType = (HTMLPART)Enum.Parse(typeof(HTMLPART), PartName);

3.枚举变量获取INT值
int i=(int)HTMLPART.LOG


posted @ 2013-01-06 10:26  gnhao  阅读(247)  评论(0编辑  收藏  举报