C# 获取自定义Attribute

ACKD:自定义类。

 

object[] s =typeof(ACKD).GetCustomAttributes(true);//获取该类上施加的 Attribute

 

System.Reflection.PropertyInfo[] propertyInfoArray = typeof(ACKD).GetProperties();//获取该类的所有属性集合
propertyInfoArray[0].GetCustomAttributes(true);//取得属性集合0元素的Attribute

 

 

System.Reflection.MethodInfo[] methodInfoArray = typeof(ACKD).GetMethods();//获取该类的所有方法集合
methodInfoArray[0].GetCustomAttributes(true);//取得方法集合0元素的Attribute

posted on 2012-04-24 17:26  harry 刘  阅读(1373)  评论(0)    收藏  举报