在C#中要想将一个类序列化为XML,则使用XmlSerializer类:
XmlSerializer serializer = new XmlSerializer(typeof(PurchaseOrder));
TextWriter writer = new StreamWriter(filename);
PurchaseOrder po=new PurchaseOrder();
// Serialize the purchase order, and close the TextWriter.
serializer.Serialize(writer, po);
writer.Close();
可以参考WebService生成代理类的结构
时间: 2024-11-01 14:19:11