ccmny

Deep Clone C#

Jan 4th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.29 KB | None | 0 0
  1. public static object DeepClone(object obj)
  2. {
  3.   object objResult = null;
  4.   using (MemoryStream  ms = new MemoryStream())
  5.   {
  6.     BinaryFormatter  bf =   new BinaryFormatter();
  7.     bf.Serialize(ms, obj);
  8.  
  9.     ms.Position = 0;
  10.     objResult = bf.Deserialize(ms);
  11.   }
  12.   return objResult;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment