使用XmlSerializer序列化List對象成XML格式 序列化成XML格式,和反序列化原格式 復(fù)制代碼代碼如下: List<Customer> lst = new List<Customer>(); Customer c = new Customer(); c.ID = 1; c.Name = "one"; lst.Add(c); c = new Customer(); ...
stringwriter,xmlserializer將對象、對象集合序列化為xml格式的字符串, 同時描述如何進(jìn)行反序列化. c# 序列化 xmlserializer,binaryformatter,soapformatter 復(fù)制代碼代碼如下: //radio.cs using system; using system.collections.generic; using system.text;
public static object Deserialize(Type type, string xml) { try { xml = xml.Replace("\r\n", "").Replace("\0", "").Trim(); using (StringReader sr = new StringReader(xml)) { XmlSerializer xmldes = new XmlSerializer(type); return xmldes.Deserialize(sr); ...