📜  c# 序列化为 xml - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:40.139000             🧑  作者: Mango

代码示例1
XmlSerializer xsSubmit = new XmlSerializer(typeof(MyObject));
 var subReq = new MyObject();
 var xml = "";

 using(var sww = new StringWriter())
 {
     using(XmlWriter writer = XmlWriter.Create(sww))
     {
         xsSubmit.Serialize(writer, subReq);
         xml = sww.ToString(); // Your XML
     }
 }