[Mono-list] Making a copy of a class instance
Sergio Duran
Sergio Duran <sergioduran@gmail.com>
Tue, 25 Jan 2005 10:46:47 -0600
Hi everybody,
I want to make a copy of class instance, but I know classes are
asigned by reference, so doing
myClass class1=new Class();
myClass class2=class1;
is the same as working with pointers, and class2 becomes an alias of
class1, I want to make class2 an independent copy of class1, and be
able to change values in each one of the instance and not touching the
other instance.
I'm thinking about doing a myClass ctor with a myClass argument and
manually copy every variable of the source instance, to the new
instance, but I dont think that's the best aproach.
isnt there a myClass class2=duplicate class1?