public static T CreateDeepCopy<T>(T obj)
{
T t;
MemoryStream memoryStream = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(memoryStream, obj);
memoryStream.Position = 0;
t = (T)formatter.Deserialize(memoryStream);
return t;
}
网友评论