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 be 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 method object Clone(); }
Implemented By
Multiple types