在C#中的ICloneable中给出的Clone方法只是一个模棱两可的方法,并不足以实现深拷贝和浅拷贝。
深拷贝:
using(Stream objectStream = new MemoryStream()) { IFormatter formatter = new BinaryFormatter(); formatter.Serialize(objectStream, this); objectStream.Seek(0, SeekOrigin.Begin); return formatter.Deserialize(objectStream) as Test; }
使用using开出一段流,将对象序列化
标签:序列化,objectStream,new,using,拷贝,formatter From: https://www.cnblogs.com/wen-chen/p/16975216.html