C# 如何使用.Net泛型继承模板参数?
我希望能够做到这一点。C# 如何使用.Net泛型继承模板参数?,c#,.net,generics,C#,.net,Generics,我希望能够做到这一点。 MyInterface interface = new ServiceProxyHelper<ProxyType>(); 这行吗? public class ProxyType : MyInterface {} public class ServiceProxyHelper<ProxyType> : IDisposable, MyInterface {} 公共类代理类型:MyInterface{} 公共类ServiceProxyHelper:
MyInterface interface = new ServiceProxyHelper<ProxyType>();
这行吗?
public class ProxyType : MyInterface {}
public class ServiceProxyHelper<ProxyType> : IDisposable, MyInterface {}
公共类代理类型:MyInterface{}
公共类ServiceProxyHelper:IDisposable,MyInterface{}
我想这就是你想要做的:
public class ServiceProxyHelper<T> where T : MyInterface { ... }
公共类ServiceProxyHelper,其中T:MyInterface{…}
相关问题:public class ServiceProxyHelper<T> where T : MyInterface { ... }