c# XML序列化
public static T Deserialize<T, S>(S stream) where S : Stream where T : class, new() { using (stream) { XmlSerializer xmlSearializer = new XmlSerializer(typeof(T)); // fileStream.Position = 0; // fileStream.Seek(0, SeekOrigin.Begin); return (T)xmlSearializer.Deserialize(stream); } } public static void Serialize<T, S>(T obj, S stream) where S : Stream where T : class, new() { using (stream) { XmlSerializer xmlFormat = new XmlSerializer(typeof(T)); xmlFormat.Serialize(stream, obj); } }
从此山高路远,纵马扬鞭。愿往后旅途,三冬暖,春不寒,天黑有灯,下雨有伞。此生尽兴,不负勇往。