I have something which should be easy to answer for most of your I think:
I have the following classes:
class One
{
string first;
}
class Two : One
{
string second;
}
Now I wanted to replace all One values of a Two value. So I tried the following:
One one = new One();
Two two = new Two();
two = (Two) one; // <= this seems to not work
So do I really have to implement a Method that copys all members of one to two?
In short: Yes
Like what was already said, One doesn’t inherit from Two, so there’s no “logical” default action to take here.
You should look into Conversion Operators. This’ll let you still use the two=(Two) one syntax after defining an operator, like this(in the class def):