Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

Object.MemberwiseClone Method

Creates a shallow copy of the current instance (object) of the Object class.

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


[MethodImplAttribute]
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, and 4.1.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.