We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

duplicate object

Thread ID:

Created:

Updated:

Platform:

Replies:

1040 Sep 16,2002 05:51 PM Sep 21,2002 08:07 AM Windows Forms 1
loading
Tags: FAQ
JH
Asked On September 16, 2002 05:51 PM

I have objA and objB, both derived from the same class. how do i copy the contents of b into a? i don't want to do this: objA = objB because that sets a's reference to b. this is something that has to be very simple to do, but i'm at a loss. thanks!

Stefan Hoenig [Syncfusion]
Replied On September 21, 2002 08:07 AM

You have to write such a function yourself. If you call it for example "CopyTo" you could then do objB.CopyTo(obja) If on the other side you want to create a new object that is an exact copy of your object, you should provide a Clone method. See the following methods and interfaces in the SDK Class Referecne for more information: ICloneable, Clone, MemeberwiseClone. Stefan > I have objA and objB, both derived from the same class. how do i copy the contents of b into a? i don't want to do this: > > objA = objB > > because that sets a's reference to b. this is something that has to be very simple to do, but i'm at a loss. > > thanks!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;