For some context - this is an extension of an earlier question.
override List<baseClass> with List<derivedClass>
Anyway,
I have a generic base class "Scene"
public class Scene<T> where T: SceneModel { }
I also have two classes which inherit from this:
public class WorldScene : Scene<WorldModel> { }
public class BattleScene : Scene<BattleModel> { }
Now what I need to do is have a List<Scene<SceneModel>>
which contains a mixture of WorldScene and BattleScene. Where I need the list I am obviously only needing to use the properties/methods common to WorldScene and BattleScene.
I get that they are two distinctly different objects - but given that they inherit from the same thing - I'm hoping there's some clever way of grouping them in this way without manually casting them to some third type.