|
|
System.ICloneable Interface |
|
|
Description | |
|
Cloning is the process of making a new object instance (rather than reference to an existing instance) that contains a clone of the contents of the original object instance.
The ICloneable interface provides just the Clone method that must be implemented.
In general, cloning has two forms :
Shallow | Top level objects are copied in value, lower levels by reference |
Deep | All objects are copied in value |
It is entirely up to the discretion of the implementing class as to which approach they take. For example, the Array Clone method is a shallow copy.
Be wary about shallow copies - updating lower level objects affects both the current (cloned) and original objects.
|
|
Delphi Basics links | |
|
|
Microsoft MSDN links | |
|
|
|
|
|
|