I was challenged recently with a question about generics with constraints.
The claim was that it’s only a compile flaw that allows your to declare an interface for a generic type with a constraint. Namely that the syntax
public interface ISomething <T> where T: SomeClass
would pass compilation but would not be useful (runtime) because you can’t declare a variable
ISomething myVar = new ISomething<SomeClass>();
or something to that extent. I went home feeling a bit uneasy about the discussion, then coded this up the way I see it. While it is completely true that you can’t ‘new’ an interface, _using _an interface that has a generic type is completely possible and legal.
Here it is in all it’s g(l)ory.