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?
While in shallow copy the members of the copied object refer to the same object as the original object, in a deep copy, separate instances of each of the reference type members in the original instance is created in the new or cloned instance.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With