Let's assume I have a business case I want to use some model to represent a master-child structure. And there will be certain classes to inherit from both the master class and child class.
I use the sample below
public abstract class BaseChild
{
public int MyProperty { get; set; }
}
public abstract class BaseMaster
{
public abstract ReadOnlyCollection<BaseChild> Children { get; }
}
Now I need real classes to inherit from them. So have following
public class FirstRealChild : BaseChild
{
public int AdditionalProperty { get; set; }
}
public class FirstRealMaster : BaseMaster
{
public ReadOnlyCollection<FirstRealChild> Children { get; }
}
Of course it won't compile because of the error
'FirstRealMaster' does not implement inherited abstract member 'BaseMaster.Children.get'
I can remove the public abstract ReadOnlyCollection<BaseChild> Children { get; }
from BaseMaster
class, but it loses the constraint to all inherited classes that children are required.
Anybody has some better idea?