在C#中,我如何检查属性上是否应用了XmlIgnore属性?

3
我想检查propertyInfo以确定是否应用了XmlIgnore属性于给定的属性。 我该怎么做?
2个回答

11
bool b = type.GetProperty("MyProp")
             .GetCustomAttributes(false)
             .Any(a => a is XmlIgnoreAttribute);

0
typeof(string).GetProperty("Length").GetCustomAttributes(typeof(some attr))

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接