What Does Shallow Copy Mean?

Shallow copy, in C#, is the process of creating a clone of an object by instantiating a new instance of the same type as original object and copying the non-static members of the existing object to the clone. The members of the value type are copied bit by bit while the members of the reference type are copied such that the referred object and its clone refer to the same object.

Techopedia Explains Shallow Copy

Shallow copy is similar to deep copy in the assignment of each member of an object to that of another object, but it differs in the manner in which the field of reference type is copied. Unlike in shallow copy where the reference is only copied, in deep copy, a new copy of the referred object is created.

  • Call the MemberwiseClone method of the object Create a clone manually through a custom method that is tedious but easy to controlUse a reflection technique that provides automated facility to perform shallow copy, but with performance overheadUse a serialization method that is slower than reflection but automated and simple