After struggling with downcasting (see [my original post] ) and using [deep copies] , I found [this article of the same name] , where in C ++ it was suggested how to deal with this problem. With great excitement, I implemented it in C # as follows:
public partial class User
{
virtual public Employer GetEmployer() { return null; }
...
}
public partial class Employer
{
public override Employer GetEmployer() { return this; }
...
}
which I then used as follows:
User u = GetUser();
Employer e = u.GetEmployer();
However (I suppose not surprisingly), an override is never called and returns null.
, , - , , : , , . , () .
-, -, , User, . ( ), , Employer, User.
?