public static T DeepCopyByBinStream<T>(T obj) { object ret; using (MemoryStream ms = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ms, obj); ms.Seek(0, SeekOrigin.Begin); ret= bf.Deserialize(ms); } return (T)ret; }
public static T DeepCopyByBinStream<T>(T obj) { object ret; using (MemoryStream ms = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ms, obj); ms.Seek(0, SeekOrigin.Begin); ret= bf.Deserialize(ms); } return (T)ret; }