Let's assume we have following classess:
abstract class Vehicle {/**/}
class Truck : Vehicle {/**/}
class Bus : Vehicle {/**/}
//etc...
abstract class VehicleWheel<TVehicle> where TVehicle : Vehicle {/**/}
class TruckWheel : VehicleWheel<Truck> {/**/}
class BusWheel : VehicleWheel<Bus> {/**/}
Now, i want to create generic class "VehicleWheelCarrier", which is inherited from Vehicle, and has 1 parameter, which is any type of wheel:
abstract class VehicleWheelCarrier<TWheel> : Vehicle where TWheel:VehicleWheel
Unfortunatelly, this doesn't compile, as VehicleWheel requires parameter.
How to solve that?
VehicleWheelCarrierdoesn't care if it carries wheels for trucks or busses or any other kind of wheel. Question is, what does it care about? What properties of any wheel does it need to do what it should do? Create an abstract superclass ofWheel(without any generics) or better yet, an interfaceIWheeland letVehicleWheel<TVehicle>inherit that, andVehicleWheelCarrieruse just that.