Reference Types

  • Thread starter Thread starter Chance Hopkins
  • Start date Start date
C

Chance Hopkins

I'm trying to figure out how to pass my custom object which inherits from an
IList interface by value. I have a group of objects I'd really like to pass
to a second form, one at a time, and have the originals remain intact.

I found the following Reference Types reference:
http://msdn.microsoft.com/library/d.../csspec/html/vclrfcsharpspec_4.asp?frame=true

So I understand why my application isn't working like I want.

Does anyone have a trick or tip for doing this? It's really starting to
drive me nuts.
 
Probably your best solution is to implement the ICloneable interface on
your objects and call the Clone method to make a copy that you pass to
the other form. You'll need to implement the Clone method by creating a
new instance of your class and setting the values in this new instance
to match the values in the original instance.

-- John
 
John Socha-Leialoha said:
Probably your best solution is to implement the ICloneable interface on
your objects and call the Clone method to make a copy that you pass to the
other form. You'll need to implement the Clone method by creating a new
instance of your class and setting the values in this new instance to
match the values in the original instance.

-- John


Thank you both. I'll get that going.
 
For the sake of the archive. Anyone that is reading this and still having
trouble, search for "deep copy".
 
Back
Top