C# 深拷贝

public static T DeepClone<T>(T obj)
{
 using (var ms = new MemoryStream())
 {
   var formatter = new BinaryFormatter();
   formatter.Serialize(ms, obj);
   ms.Position = 0;

   return (T) formatter.Deserialize(ms);
 }
}

 

posted @ 2019-09-06 16:45  Lucas_zou  阅读(150)  评论(0)    收藏  举报