Please take a look at my class structure. I think I would like to have more fun with inheritance than it is possible.
First there is a base abstract class:
public abstract class PolicyDetailed
{
internal abstract DataContainer GetActiveAsset();
}
Next there is another abstract class, which is generic:
public abstract class PolicyDetailed<T> : PolicyDetailed where T : DataContainer
{
internal new abstract T GetActiveAsset();
}
Lastly there is a specific policy class. AccidentContainer inherits from DataContainer:
public class PolicyAccident : PolicyDetailed<AccidentContainer>
{
internal override AccidentContainer GetActiveAsset()
{
return null;
}
}
During compilation I get the following error:
'PolicyAccident' does not implement inherited abstract member 'PolicyDetailed.GetActiveAsset()'
I am not sure what modifiers I should use here to get it to work. Maybe I should also write what I would like to achieve: I have a collection of policy objects of different type (e.g. PolicyAccident, PolicyTravel etc.) which inherit from PolicyDetailed with different types of DataContainer (AccidentContainer, TravelContainer etc.). I would like to call "GetActiveAsset" method on each of them without knowing their specific type and referencing them through PolicyDetailed. At the same time I would like each class to return their specific Datacontainer subclass. Is that possible?