I'm trying to create a method that through generics tries to pass an interface and a class. It should look something like this, but this does not build:
public static void Register<TInterface, TClass>()
where TClass : TInterface
where TInterface : interface // <- doesn't compile
{
...
}
Is there any way to get this to work. The idea is to build a wrapper around an ioc container.
where T : interfaceconstraint in c#, you can use only interface name. You can use something like thatwhere TClass : class, TInterface: interface? What's wrong if I provide, say, abstract class forTInterface?void Register<TService, TImplementation>() where TService: class where TImplementation : class, TService