国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

c# EnumHelper枚舉常用操作類

2020-01-24 00:55:50
字體:
來源:轉載
供稿:網友

測試代碼如下:

namespace CutPictureTest.Comm{  public class EnumHelper  {    public static System.Collections.ArrayList GetName(Type enumType)    {      System.Collections.ArrayList arr = new System.Collections.ArrayList();      string[] n = System.Enum.GetNames(enumType);      foreach (string item in n)        arr.Add(item);      return arr;    }    public static T ToEnum<T>(string strEnum)    {      T t = (T)Enum.Parse(typeof(T), strEnum);      return t;    }    public static System.Collections.Hashtable EnumToHashtable(Type enumType)    {      System.Collections.Hashtable ht = new System.Collections.Hashtable();      Array arr = System.Enum.GetValues(enumType);      for (int i = 0; i < arr.Length; i++)        ht.Add(Convert.ToInt16(arr.GetValue(i)), arr.GetValue(i).ToString());      return ht;    }  }}

調用方式:

System.Collections.Hashtable arr = Comm.EnumHelper.EnumToHashtable(typeof(tImageFormat));      foreach (string item in arr.Values)        cb.Items.Add(item);

其中的cb表示ComboBox對象,你可以替換成你的下拉框對象。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 衡东县| 渭南市| 水富县| 秦皇岛市| 满城县| 嘉峪关市| 新昌县| 嘉兴市| 南康市| 陆河县| 延川县| 竹山县| 宣化县| 绥化市| 赫章县| 广水市| 九龙城区| 东港市| 眉山市| 平和县| 兴和县| 金华市| 辽宁省| 富锦市| 巴彦县| 东丰县| 青浦区| 遂溪县| 高州市| 图木舒克市| 涿鹿县| 潼关县| 盈江县| 铜鼓县| 玉树县| 无棣县| 辽宁省| 鄂州市| 龙海市| 城市| 亳州市|