Creating a new object by copying the current instance/object.Cloning can be implemented in two ways: Shallow copy and deep copy.In Deep copy, all objects are duplicated while in Shallow copy only top-level objects are duplicated and other lower level objects are referenced.For example, consider an object 'X' that references objects 'A' and 'B'. Object 'B', in turn, references object 'C'. A shallow copy of 'X' creates new object 'X2' that also references objects 'A' and 'B'. In contrast, a deep copy of 'X' creates a new object 'X2' that references the new objects 'A2' and 'B2', which are copies of 'A' and 'B'. 'B2', in turn, references the new object 'C2', which is a copy of 'C'. The example shows the difference between a shallow and a deep copy.
source http://www.c-sharpcorner.com/Blogs/cloning-of-object-shallow-copy-and-deep-copy-in-c-sharp
No comments:
Post a Comment