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 12:07 PM UTC

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.
Up arrow icon