I have an abstract base-class and several classes deriving from that. The base-class has - against all conventions - some constructors, which I'd love to use. I'm now writing an extension method, which takes a generic type argument. This type is the return type:
public static T Create<T>(string key) where T : Baseclass { }
Now, I want to access Baseclass' constructor such as:
var item = new T(key);
Where the base-class defines the corresponding constructor.
I know, its probably a pretty bad design and there are work-arounds using reflection (naive way) or delegate-functions or putting the constructor-call outside the Create()-call.
I'm just curious why the C#-Compiler does not allow the access to the constructor of a generic type which is defined in the abstract base class, from which the generic type must derive because of the generic type constraints.
There are several questions, nearly similar, but all of them care with constraining the generic type the constructor, in my case the constraint is the class-inheritance.