.Net Generics を使用してテンプレート パラメーターを継承するにはどうすればよいですか?
質問
これができるようになりたいです。
MyInterface interface = new ServiceProxyHelper<ProxyType>();
オブジェクト構造は次のとおりです
MyTypeThatImplementsMyInterface : MyInterface
これはうまくいきますか?
public class ProxyType : MyInterface {}
public class ServiceProxyHelper<ProxyType> : IDisposable, MyInterface {}
解決
これがあなたがやろうとしていることだと思います:
public class ServiceProxyHelper<T> where T : MyInterface { ... }
所属していません StackOverflow