Xml元素在C#Xml序列化中的位置

Xml元素在C#Xml序列化中的位置,c#,.net,xml,serialization,xmlserializer,C#,.net,Xml,Serialization,Xmlserializer,我正在尝试使用XmlSerializer类将这样的类序列化为xml: public class Car { public InsuranceData Insurance { get; set; } // InsuranceData is a class with many properties public int Person Owner { get; set; } public int Age { get; set; } public string Model { get;

我正在尝试使用XmlSerializer类将这样的类序列化为xml:

public class Car {
  public InsuranceData Insurance { get; set; } // InsuranceData is a class with many properties
  public int Person Owner { get; set; }
  public int Age { get; set; }
  public string Model { get; set; }

  // lots of other properties...
}
我希望将保险属性放在xml文档的最后:

<Car>
  ...
  <Insurance>
     ...
  </Insurance>
</Car>

...
...
我之所以需要这样做,是因为处理xml的服务器只能在此布局中正常工作(而且我无法更改服务器代码)。 我尝试将属性移动到类的末尾,但是没有任何区别,我也没有找到任何与序列化相关的有帮助的属性。
我可以通过将xml作为字符串处理来解决这个问题,但我更喜欢一个更优雅的解决方案。对象有很多属性,因此我不想手动创建xml字符串。

以下是我为测试您的场景所做的:

publicstaticvoidmain(字符串[]args)
{
保险i=新保险();
i、 company=“国营农场”;
c车=新车();
c、 model=“野马”;
c、 年份=“2014年”;
c、 ins=i;
XmlSerializer xs=新的XmlSerializer(typeof(Car));
StreamWriter sw=新的StreamWriter(“Car.xml”);
xs.序列化(sw,c);
sw.Close();
}
公车
{
公共字符串模型{get;set;}
公共字符串年份{get;set;}
公共保险ins{get;set;}
}
公共类保险
{
公共字符串公司{get;set;}

}
也许你能从中找到答案