通常有两种方法可以实现此目的。
:添加另一个参数来IGarrage
表示T
应该传递给IGenericCar<T>
约束的参数:
interface IGarrage<TCar,TOther> where TCar : IGenericCar<TOther> { ... }
:定义一个基本接口,IGenericCar<T>
该接口不是通用接口,并且针对该接口进行约束
interface IGenericCar { ... }
interface IGenericCar<T> : IGenericCar { ... }
interface IGarrage<TCar> where TCar : IGenericCar { ... }