标签:
1.使用前需将要序列化的类标记为Serializable
2.
//深拷贝 public static object Clone(object obj) { //创建内存流 MemoryStream ms = new MemoryStream(); //以二进制格式进行序列化 BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ms, obj); //反序列化当前实例到一个object ms.Seek(0, 0); object res = bf.Deserialize(ms); //关闭内存流 ms.Close(); return res; }
标签:
原文地址:http://www.cnblogs.com/guosier/p/5503902.html