问题描述
|
我有一个自定义的“ 0”类型,它支持与“ 1”之间的隐式转换。我可以将该结构序列化为元素,而在公共属性上使用
XmlText
属性则没有任何问题。
struct Test
{
[XmlText]
public string Value {get(...);set(...);}
}
class Other
{
[XmlElement] // this renders as <TestElement>value</TestElement>
public Test TestElement {get; set;}
[XmlAttribute] // this fails at runtime
public Test TestElement {get; set;}
}
但是,我无法将其序列化为属性。反正有使其工作吗?解决方法
“ 4”表示将数据序列化为元素的文本值。不能用于属性。