Esempio n. 1
0
        public static string GetDescription(EnumNotifyType en)
        {
            Type type = en.GetType();                                 //获取类型

            MemberInfo[] memberInfos = type.GetMember(en.ToString()); //获取成员
            if (memberInfos != null && memberInfos.Length > 0)
            {
                DescriptionAttribute[] attrs = memberInfos[0].GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[];   //获取描述特性

                if (attrs != null && attrs.Length > 0)
                {
                    return(attrs[0].Description);    //返回当前描述
                }
            }
            return(en.ToString());
        }