Name
ICloneable
Synopsis
ICloneable
is a marker interface, indicating
that an object can be cloned (that is, have a completely identical copy
created). It consists of a single method, Clone()
,
which is called by clients wishing to create a complete copy of the ICloneable
-implementing class.
When speaking of cloning, the terms deep copy cloning and shallow copy cloning indicate how deeply into the object graph a clone operation
will carry itself. A deep copy not only clones the object called,
but in turn seeks to clone any objects to which it holds reference. This sort
of operation must be handled by the programmer, usually by calling Clone()
in turn on each object this object references.
A shallow copy is a complete bitwise copy of this
object; any objects referenced by this object are also referenced by
the cloned object.
The simplest way to implement a shallow clone is to use the Object.MemberwiseClone()
method to copy this
object’s fields directly and then return. A deep clone also calls MemberwiseClone()
, but then also asks each object
reference held within this object to Clone()
itself.
Public Interface ICloneable ' Public Instance Methods Public Function Clone() As Object End Interface
Implemented By
Multiple types
Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.