在内存中序列化,反序列化对象实体 来完成对象实体的深拷贝
代码
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using (Stream s = (Stream)(new MemoryStream()))
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(s, your_obj);
s.Position = 0;
your_obj_next = (your_obj_type)bf.Deserialize(s);
}