I have a generic class with a class constraint on it.
public class MyContainer<T> where T : MyBaseRow
MyBaseRow is an abstract class that I also want to contain some flavor of MyContainer.
public abstract class MyBaseRow { public MyContainer<MyBaseRow> ParentContainer; public MyBaseRow(MyContainer<MyBaseRow> parentContainer) { ParentContainer = parentContainer; } }
I'm having problems with class constructors inherited from MyBaseRow, for example.
public class MyInheritedRowA : MyBaseRow { public MyInheritedRowA(MyContainer<MyInheritedRowA> parentContainer) : base(parentContainer) { } }
Will not allow MyInheritedRowA in the constructor, the compiler only expects and only resolves MyBaseRow. I thought a general class constraint allowed inheritance? What am I doing wrong here and is there a way to change these classes to get around this? Thanks a lot in advance for any answers.
source share