Search code examples
.netinstancedeep-copy

Deep Copy a .NET Class Instance Without Serialization


I am using an instance class from a third-party DLL, and I need to do a deep copy on a particular instance. The class is not marked as Serializable, and therefore I can not use this suggested method using BinaryFormatter.

How can I get a deep copy of this object without using serialization?


Solution

  • I've been using Copyable with great success. It uses reflection under the hood. It is open-sourced. Be sure to read Limitations and pitfalls to see if you can use it.