XIAOJINJIN

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

using System.Collections.Generic;
using System.ComponentModel;

 

        private List<string> GetEnumInfo(Type Enum )
        {
            Type type = Enum;
            object[] CurObj =type.GetCustomAttributes(typeof(DescriptionAttribute), true);
            List<string> strDescription = new List<string>();
            foreach (DescriptionAttribute item in CurObj)
            {
                strDescription.Add(item.Description);
            }
            return strDescription;
        }
        enum Lser
        {
            [Description("NO1")]
            Lser =0,
            [Description("LserH")]
            LserH = 0,
            [Description("LserL")]
            LserL = 0,
            [Description("LserR")]
            LserR = 0,
            [Description("LserF")]
            LserF = 0,
            [Description("LserG")]
            LserG = 0,
        }
 
Client
{
    List<string> strDescripton = GetEnumInfo(typeof(Lser));
}
posted on 2020-04-28 19:08  XIAOJINJIN  阅读(995)  评论(0)    收藏  举报