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. Image for the cookie policy date

duplicate object

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!

1 Reply

SH Stefan Hoenig Syncfusion Team 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!

Loader.
Live Chat Icon For mobile
Up arrow icon