C#model序列化xml
private string Serialier<T>(T model) { using (StringWriter streamWriter = new StringWriter()) { XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); XmlSerializer xmlSerializer = new XmlSerializer(model.GetType()); xmlSerializer.Serialize(streamWriter, model,ns); return streamWriter.ToString(); } }
参数model是数据模型