<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      【C#】枚舉

      枚舉

      public static class CommonEnums
          {
              public enum people
              {
                  /// <summary>
                  ///男人
                  /// </summary>
                  [Description("男人")]
                  man = 1,
                  /// <summary>
                  /// 女人
                  /// </summary>
                  [Description("女人")]
                  women = 2,
              }
      }

      string->枚舉

      CommonEnums.people en = (CommonEnums.people)Enum.Parse(typeof(CommonEnums.people), "women");

      枚舉->Dictionary

      //使用:生成一個dictionary
      Dictionary<int, string> dic=CommonEnums.people.man.ToEnumDictionary();
      
      //靜態方法
      public static class EnumExtension
          {
              public static Dictionary<int, string> ToEnumDictionary(this Enum enumT, string category = "")
              {
                  Type enumType = enumT.GetType();
                  if (!enumType.IsEnum) throw new Exception("參數不是枚舉");
      
                  var array = enumType.GetEnumValues();
                  if (array.Length < 1) return new Dictionary<int, string>(1);
                  Dictionary<int, string> result = new Dictionary<int, string>(array.Length);
      
                  int[] enumValues = new int[array.Length];
                  int index = 0;
      
                  foreach (var item in array)
                  {
                      enumValues[index] = Convert.ToInt32(item);
                      ++index;
                  }
      
                  var enumNames = enumType.GetEnumNames();
                  DescriptionAttribute[] descriptions = null;
                  CategoryAttribute[] categorys = null;
      
                  for (index = 0; index < array.Length; ++index)
                  {
                      FieldInfo fi = enumType.GetField(enumNames[index]);
                      descriptions = fi.GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[];
      
                      if (category != string.Empty)
                      {
                          categorys = fi.GetCustomAttributes(typeof(CategoryAttribute), false) as CategoryAttribute[];
                          if (categorys != null && categorys.Length > 0)
                          {
                              if (categorys[0].Category != category)
                              {
                                  continue;
                              }
                          }
                      }
      
                      if (descriptions != null && descriptions.Length > 0)
                      {
                          result.Add(enumValues[index], descriptions[0].Description);
                      }
                      else
                      {
                          result.Add(enumValues[index], string.Empty);
                      }
                  }
      
                  return result;
              }
          }

      獲取枚舉描述

      //使用
      string desc = CommonEnums.people.man.GetDescription();
      //方法
      public static string GetDescription(this Enum value, bool nameInstend = true)
              {
                  Type type = value.GetType();
                  string name = Enum.GetName(type, value);
                  if (name == null)
                  {
                      return null;
                  }
                  FieldInfo field = type.GetField(name);
                  DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
                  if (attribute == null && nameInstend == true)
                  {
                      return name;
                  }
                  return attribute == null ? null : attribute.Description;
              }

       

       

       

       

       

      posted @ 2017-05-04 15:44  Doc.stu  閱讀(299)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 人妻蜜臀久久av不卡| 国产精品亚洲二区亚瑟| 成人免费A级毛片无码片2022| 精品91在线| 亚洲精品成人久久久| 无码粉嫩虎白一线天在线观看 | 91精品国产一二三产区| 国产精品国产精品偷麻豆| 超清无码一区二区三区| 亚洲国产精品成人综合色| 综合激情丁香久久狠狠| 亚洲人成网线在线播放VA| 国产精品自在拍首页视频8| 92国产精品午夜福利免费| 亚洲成精品动漫久久精久| 日韩精品 在线 国产 丝袜| 日韩精品射精管理在线观看| 中文国产成人精品久久一| 影音先锋啪啪av资源网站| 日韩理伦片一区二区三区| 国产精品午夜精品福利| 三级三级三级A级全黄| 亚洲av成人网在线观看| 亚洲另类激情专区小说婷婷久| 日韩秘 无码一区二区三区| 极品美女扒开粉嫩小泬图片 | 白嫩少妇无套内谢视频| 老司机亚洲精品一区二区| 日日噜噜大屁股熟妇| 国产av第一次处破| 无码囯产精品一区二区免费| 日本东京热一区二区三区| 霍林郭勒市| 国产日女人视频在线观看| 国产精品美女久久久| 尤物蜜芽国产成人精品区| 久久日韩精品一区二区五区| caoporn免费视频公开| 亚洲成年轻人电影网站WWW| 国产精品福利自产拍在线观看| 日本一区二区在线高清观看|