public interface IFoo
public class Foo : IFoo
public interface ILang<T> where T:IFoo
public class Lang : ILang<Foo>
但是现在,我想要这样的带通配符的东西
public class CarroMontadora<T> where T:ILang<?>
因为这不适用于我的界面:
public class MYCLASS<T> where T:ILang<IFoo>
这不是太聪明,因为不是那么泛型:
public class MYCLASS<T,U> where T:ILang<U> where U: IFoo
最佳答案
您必须向新类添加另一个通用参数:
public class CarroMontadora<T1, T2>
where T2 : IFoo
where T1 : ILang<T2>
{
}
关于c# - 泛型双接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21054666/