How do I use .Net Generics to inherit a template parameter?
Question
I want to be able to do this.
MyInterface interface = new ServiceProxyHelper<ProxyType>();
Here's the object structure
MyTypeThatImplementsMyInterface : MyInterface
Will this work?
public class ProxyType : MyInterface {}
public class ServiceProxyHelper<ProxyType> : IDisposable, MyInterface {}
Solution
I think this is what you're trying to do:
public class ServiceProxyHelper<T> where T : MyInterface { ... }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow