Unfortunately, this is not possible. The "this" reference can not be
assigned to. You will have to copy the emembers of the my_person parameter
to your instance, and have two instances.
You might want to look into the IClonable interface, as it is what is
used to indicate that a copy of an object can be made. The semantics of
that copy (shallow or deep) is up to the implementer.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"NOSPAM" <no****@xsagfgsagsafg.com> wrote in message
news:8o********************@rogers.com...
I have a class, see below. what I want to do is to load the "person" object
to itself, what is the correct way to do?
public class person {
public string first_name = "";
public string last_name = "";
public string address = "";
public void loadme (person my_person) {
// (A) this works
this.first_name = ((person) my_person).first_name;
// (B) how to load the whole object to itself? this is not
working.
this = my_person;
}
}
Help... please.