There are typically 2 ways to achieve this.
Option1: Add another parameter to IGarrage
representing the T
which should be passed into the IGenericCar<T>
constraint:
interface IGarrage<TCar,TOther> where TCar : IGenericCar<TOther> { ... }
Option2: Define a base interface for IGenericCar<T>
which is not generic and constrain against that interface
interface IGenericCar { ... }
interface IGenericCar<T> : IGenericCar { ... }
interface IGarrage<TCar> where TCar : IGenericCar { ... }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…