【发布时间】:2010-01-29 03:18:01
【问题描述】:
有谁知道我如何使用 Convert.ChangeType 从 XML 转换为特定的类?
例如:
我的财产
public Point Loc
{
get { return GetValue<Point2D>("Loc"); }
set { SetValue<Point2D>("Loc", value); }
}
我的 XML:
<Loc>
<X>1.0</X>
<Y>1.0</Y>
</Loc>
调用转换:
prop.SetValue(targetObj,
Convert.ChangeType(xmlProperty.Value, prop.PropertyType));
我已经研究过使用 IConvertible,但没有调用任何方法。
我能找到的所有示例都使用简单类型。没有显示转换为类的实例。
谢谢,
瑞克
【问题讨论】:
标签: c# xml reflection