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

首頁 > 編程 > C# > 正文

c# EnumHelper枚舉常用操作類

2019-10-29 21:18:46
字體:
來源:轉載
供稿:網友

測試代碼如下:

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對象,你可以替換成你的下拉框對象。

 

注:相關教程知識閱讀請移步到c#教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乐都县| 左贡县| 景泰县| 昭通市| 黄石市| 德江县| 武鸣县| 正阳县| 大荔县| 海兴县| 锦屏县| 界首市| 枝江市| 云浮市| 临汾市| 阳泉市| 双柏县| 铁岭市| 南昌县| 黄山市| 博客| 呈贡县| 武义县| 四平市| 抚州市| 维西| 昌邑市| 化隆| 钦州市| 永德县| 南投县| 广宗县| 龙胜| 阿拉善右旗| 咸阳市| 乐业县| 仙居县| 时尚| 肇东市| 宜丰县| 龙海市|