.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