0
我有一个自定义struct
类型,支持向和从string
的隐式转换。我可以序列化这个结构作为一个元素,在公共属性上使用XmlText
属性没有任何问题。自定义类型为XMLAttribute
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;}
}
但是,我不能序列化它作为一个属性。无论如何要使它工作?
我有点知道,我想知道的是我怎样才能使它作为一个**属性**,我的类型是隐式可转换为和从字符串,所以如果我可以使它显示为一个字符串它会工作。 – 2011-04-19 02:46:59