Please explain shallow copying in .net
what is meant by shallow copying in .net ?
Collapse
X
-
The difference between a "shallow" copy and a "deep" copy is in the number of levels of nested objects/items are copied.
For example, presume you have a object with a structure as follows:
Person
-FirstName (string)
-LastName (string)
-PhoneNumber (string)
-Children (Collection<Pers on>)
In the case of a shallow copy, only the FirstName, LastName and PhoneNumber (first level properties) would/should be copied. In the case of a deep copy, you would recurse through all the child objects and create copies of those as well into the new object.
Comment