I'm writing a routine in C# that is designed to copy an object after casting into the object that contains the routine.
Sample Code:
public void SetObjectData(object objectInDisguise)
{
Member objectToCopy = (Member)objectInDisguise;
_field1 = objectToCopy._field1;
_field2 = objectToCopy._field2;
}
Null pointer exceptions and weak variable names notwithstanding, is there any way that I can simply cast the object to the Member
class and copy the reference to this into my current Member
object?
I tried something like:
this = objectToCopy;
but this
is read-only, so the compiler didn't let me. Just wondering if anyone knew how one could manage this.