I would like to implement a generic C# class which looks roughly as follows:
abstract class Foobar<T> : AbstractBase, T
{ ... }
This fails because C# will only allow types after the base class to be interfaces, so next I try this:
abstract class Foobar<T> : AbstractBase, T where T : interface
{ ... }
But then I find that C# does not allow this form of type constraint. Only where T : struct
and where T : class
are allowed.
How can I dictate that a type parameter must only be an interface type?