【发布时间】:2009-06-19 15:55:38
【问题描述】:
我有一个具有一些基本属性的类...
[XmlAttribute("MyFirstProperty")]
public string FirstProperty { get; set; }
[XmlAttribute("MySecondProperty")]
public string SecondProperty { get; set; }
使用反射,我可以枚举公共属性并为上面的每个属性获取 PropertyInfo 对象......我现在唯一需要的是一种方法:
- 检测属性是否具有 XmlAttribute(我认为这可以通过 PropertyInfo.IsDefined(typeof(XmlAttribute), true) 工作,但想确定)
- 获取XmlAttribute的字符串值
这是怎么做到的?
【问题讨论】:
标签: c# reflection