
📝 What is deep or shallow copy concept in C#?
🔸 Shallow Copy is about copying an object's value type fields into the target object and the object's reference types are copied as references into the target object but not the referenced object itself. It copies the types bit by bit. The result is that both instances are cloned and the original will refer to the same object.
🔸 Deep Copy is used to make a complete deep copy of the internal reference types, for this we need to configure the object returned by
In other words a deep copy occurs when an object is copied along with the objects to which it refers.
#post
🔸 Shallow Copy is about copying an object's value type fields into the target object and the object's reference types are copied as references into the target object but not the referenced object itself. It copies the types bit by bit. The result is that both instances are cloned and the original will refer to the same object.
🔸 Deep Copy is used to make a complete deep copy of the internal reference types, for this we need to configure the object returned by
MemberwiseClone()
.In other words a deep copy occurs when an object is copied along with the objects to which it refers.
#post