ReflectionHelperCreateDeepCopy Method
Creates a deep copy of an object.
Namespace: Common.Core.ClassesAssembly: Common.Core (in Common.Core.dll) Version: 2.1.5
public static Object? CreateDeepCopy(
Object? obj
)
- obj Object
- Object to copy.
Object is returned if the object could not be copied.
When a deep copy operation is performed, the cloned object can be modified
without affecting the original object.
The Object.MemberwiseClone method creates a shallow copy by creating a new object,
and then copying the non-static fields of the current object to the new object.
If a field is a value type, a bit-by-bit copy of the field is performed.
If a field is a reference type, the reference is copied but the referred object
is not; therefore, the original object and its clone refer to the same object.
This method is meant for simple Model classes, more complex classes are
supported but because it is written using reflection it can be somewhat slow and cause
performance issues.