C# 反射 如何获取类中属性的特性?

我定义了一个可以修饰在属性上的特性类如下
[AttributeUsage(AttributeTargets.Property,Inherited=false,AllowMultiple=true)]
我可以获取修饰类中的特性,修饰属性的特性应该是一个集合的吧?
分数不多,麻烦高人解答下怎么获取?

第1个回答  推荐于2016-06-11
Type t = typeof(Program);
foreach (PropertyInfo p in t.GetProperties()) {
object[] o = p.GetCustomAttributes(true);
}本回答被提问者采纳
相似回答