This document is archived and information here might be outdated.  Recommended version.


ObjectCopy CoClass (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > ArcObjects namespaces > System > ESRI.ArcGIS.esriSystem > Classes > O > ObjectCopy CoClass (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (System)  

ObjectCopy CoClass

CoClass to copy objects by value.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Provides a mechanism to duplicate an object using an objects persistence mechanism (IPersistStream). The objects state is written to a temporary stream and then "rehydrated" from that stream into a new instance of the object. This process is also known as a 'deep clone' as an object will also duplicate all sub objects that it contains. Even if the object supports IClone, you may still want to use ObjectCopy since it does a full copy or 'deep clone' of the object.

Supported Platforms

Windows, Solaris, Linux

Interfaces

Interfaces Description
IObjectCopy Provides access to members to copy objects by value. The object must support IPersistStream to be copied.

Remarks

ObjectCopy is useful for copying objects such as symbols or elements, particularly in cut-and-paste operations. Be careful, however, when using it on high-level objects such as Map. Objects which have a complicated state may not be fully reinitialized by their IPersistStream implementation, so ObjectCopy may not result in an object that is fully ready to participate with other objects. This is particularly true when using IObjectCopy::Overwrite to replace an object.