Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MemberwiseClone Method

Object.MemberwiseClone Method

.NET Micro Framework 3.0
Creates a shallow copy of the current instance (object) of the Object class.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

protected Object MemberwiseClone ()

Return Value

A shallow copy of the current object.

The MemberwiseClone method cannot be overridden, and it is accessible only through this class or a derived class. Use a class that implements the ICloneable interface if a deep or shallow copy of an object needs to be publicly exposed to users.

A shallow copy creates a new instance of the same type as the original object, and then it copies the nonstatic fields of the original object. If the field is a value type, a bit-by-bit copy of the field is performed. If the field is a reference type, the reference is copied but the referenced object is not, with the result that the reference in the original object and the reference in the clone point to the same object. By contrast, a deep copy of an object duplicates everything that is directly or indirectly referenced by the fields in the object.

Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, 4.1, and 4.2.

Community Additions

© 2015 Microsoft