我有两个要排序的元素,这意味着我必须使用XmlElementAttribute。但是当我添加时,我总是收到错误消息。
[System.Xml.Serialization.XmlAttribute()]
public string Name
{
get
{
return this.Name;
}
set
{
this.Name = value;
}
}
[System.Xml.Serialization.XmlAttribute()]
public int Age
{
get
{
return this.Age;
}
set
{
this. = value;
}
}
我希望首先显示姓名,然后显示年龄,所以我尝试了 到XmlElementAttribute(order = ...),但是正如我所说,我一直在出错。 除了一切正常。所以我有什么办法可以同时使用它们而不会出错。
更新
[System.Xml.Serialization.XmlAttribute()]
[System.Xml.Serialization.XmlElementAttribute(order = 1)]
public string Name
{
get
{
return this.Name;
}
set
{
this.Name = value;
}
}
[System.Xml.Serialization.XmlAttribute()]
[System.Xml.Serialization.XmlElementAttribute(order = 2)]
public int Age
{
get
{
return this.Age;
}
set
{
this. = value;
}
}
错误:(System.ArgumentNullException:值不能为空)