标签:
public static T Clone<T>(T RealObject) { using (Stream stream = new MemoryStream()) { XmlSerializer serializer = new XmlSerializer(typeof(T)); serializer.Serialize(stream, RealObject); stream.Seek(0, SeekOrigin.Begin); return (T)serializer.Deserialize(stream); } }
c#框架中提供的copy基本都是浅复制,这样序列化可以做到深复制。
标签:
原文地址:http://www.cnblogs.com/hbhzz/p/4252873.html