Live Chat Icon For mobile
Live Chat Icon

How can I use MemoryStream to create a deep clone of a serializable object ?

This can be done as follows.


public static class SerializationUtil
   static public T Clone(T source)

      IGenericFormatter formatter = new GenericBinaryFormatter(); 
      Stream stream = new MemoryStream(); 

      T clone = formatter.Deserialize(stream);
      return clone;
//Rest of SerializationUtil

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.