In object cloning you can create new same copy of object of same class type. The invoking object without knowing the type in advance.
For example:
void Test(ICloneable original) { var myCloned = original.Clone(); }
Here cloned is of the same runtime type as original, and you did not need to know what that type was to perform the cloning.
However the usefulness of ICloneable is pretty much none, because it does not define the semantics of the clone operation: is it a shallow copy or a deep copy? Since the interface does not mandate one or the other, you can't really know what you are getting back. And since knowing that is essential because you need to handle the clone accordingly, ICloneable itself is pretty much a burned card.
Liked By
Write Answer
What is the purpose of Clone() in C#?
Join MindStick Community
You have need login or register for voting of answers or question.
shreesh chandra shukla
31-Jul-2013Hi!
In object cloning you can create new same copy of object of same class type. The invoking object without knowing the type in advance.
For example:
Here cloned is of the same runtime type as original, and you did not need to know what that type was to perform the cloning.
However the usefulness of ICloneable is pretty much none, because it does not define the semantics of the clone operation: is it a shallow copy or a deep copy? Since the interface does not mandate one or the other, you can't really know what you are getting back. And since knowing that is essential because you need to handle the clone accordingly, ICloneable itself is pretty much a burned card.