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

Nir*_*ngh 2 c#

我想检查propertyInfo以确定XmlIgnore属性是否应用于给定属性.我怎样才能做到这一点?

L.B*_*L.B 10

bool b = type.GetProperty("MyProp")
             .GetCustomAttributes(false)
             .Any(a => a is XmlIgnoreAttribute);
Run Code Online (Sandbox Code Playgroud)