PDA

Click to See Complete Forum and Search --> : How do I create a New copy of a Class


ljlevend
Aug 9th, 2002, 08:59 AM
Is there a way to create a new copy a class? For example, if myClass1 and myClass2 are Classes of the same Type and you set myClass2 = myClass1, then properties in myClass2 will change if properties in myClass1 change. I want it so that myClass2 is a new instance that is identical to myClass1.

Thanks. Lance

Edneeis
Aug 9th, 2002, 10:02 AM
It depends on the class, most classes should have a clone method that you can use:
myClass2=myClass1.Clone

If not you could serialize it or maybe there is another way.

ljlevend
Aug 9th, 2002, 12:32 PM
serialize sounds like an interesting idea. i'll look into it.