获取类的描述信息 DescriptionAttribute

        static void Main(string[] args)
        {
            var attrs = typeof(TestClass).GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), true);
            if (attrs.Length > 0)
            {
                var descriptionAttribute = attrs[0] as System.ComponentModel.DescriptionAttribute;
                if (descriptionAttribute != null)
                    Console.WriteLine(descriptionAttribute.Description);
            }
            Console.ReadKey();
        }

 

posted @ 2017-09-07 08:42  上古时期的码农  阅读(511)  评论(0编辑  收藏  举报