我遇到了一个奇怪的问题,我正在努力反对......
我有这样一个类:
[XmlRoot("DoesntWork")]
class Root
{
[XmlElement(ElementName="WontWork", Order=1)]
public string xmlOutPropertyName
{...}
}
我正在用这个连载:
textBox1.Clear();
Root rt = new Root();
rt.xmlOutPropertyName = "[0000000001]";
XmlSerializer serializer = new XmlSerializer();
textBox1.Text = serializer.Serialize(rt);
但我总是得到返回类和属性名称的 xml,而不是我想要的名称。
<Root>
<xmlOutPropertyName>[0000000001]</xmlOutPropertyName>
</Root>
知道为什么会这样吗?
最佳答案
愚蠢的错误,我没有注意并使用了错误的序列化库。
关于c# - 序列化时忽略 XML 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32216649/