ObjectExtensionsDeepCloneT(T, FuncObject, Object) Method
Clones an object by deep cloning.
KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.0.0
public static T DeepClone<T>(
this T obj,
Func<Object, Object?>? customClone
Public Shared Function DeepClone(Of T) (
obj As T,
customClone As Func(Of Object, Object)
) As T
static T DeepClone(
Func<Object^, Object^>^ customClone
static member DeepClone :
obj : 'T *
customClone : Func<Object, Object> -> 'T
- obj T
- The object to clone.
- customClone FuncObject, Object
- An optional delegate that can be used to customize the cloning of individual instances.
If specified, then it is always called with a non- instance.
If it returns , then the input object will be cloned by using the default logic.
- Type of the object
The clone of the object.In Visual Basic and C#, you can call this method as an instance method on any object of type T
. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic)
or Extension Methods (C# Programming Guide)
If customClone is , then this method returns a functionally equivalent clone of the original object.
String, Delegate and runtime Type instances are not cloned but their original reference is returned in the result.
This can be overridden by handling these types in customClone.