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
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