在内存中序列化,反序列化对象实体 来完成对象实体的深拷贝

代码
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);
}

 

posted @ 2009-12-23 12:49  liulun  阅读(447)  评论(0编辑  收藏  举报