我希望能够做到这一点。

MyInterface interface = new ServiceProxyHelper<ProxyType>();

这是对象结构

MyTypeThatImplementsMyInterface : MyInterface

这行得通吗?

public class ProxyType : MyInterface {}

public class ServiceProxyHelper<ProxyType> : IDisposable, MyInterface {}
有帮助吗?

解决方案

我认为这就是你想要做的:

public class ServiceProxyHelper<T> where T : MyInterface { ... }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top