Can someone please tell me if there is any way to do this easily in C#:
x = new MyClass( );
y = new MyClass( );
I want to copy the values from y to x, without it resulting in the
construction of a new instance of MyObject( ). It is a deep copy, but
without the new instance that comes from using ICloneable.Clon e( ) (MyClass
itself comprises just ints and strings).
The reason I am looking for this behaviour is I want to have "binder"
objects associated with the members of "x". If the x object reference
changes, obviously the binders won't be able to see the underlying changes
being made (since they will still be looking at the old reference).
This may not even be the best way to go about this. This is trivial to do in
C++ so I'm a little lost in terms of doing the same thing in C#. Of course,
my strategy might be entirely inappropriate for C# so I'm happy for others
to suggest a better strategy.
x = new MyClass( );
y = new MyClass( );
I want to copy the values from y to x, without it resulting in the
construction of a new instance of MyObject( ). It is a deep copy, but
without the new instance that comes from using ICloneable.Clon e( ) (MyClass
itself comprises just ints and strings).
The reason I am looking for this behaviour is I want to have "binder"
objects associated with the members of "x". If the x object reference
changes, obviously the binders won't be able to see the underlying changes
being made (since they will still be looking at the old reference).
This may not even be the best way to go about this. This is trivial to do in
C++ so I'm a little lost in terms of doing the same thing in C#. Of course,
my strategy might be entirely inappropriate for C# so I'm happy for others
to suggest a better strategy.
Comment