Relative Content

Tag Archive for c#oopgenerics

C#: Possible to create type hierarchy between generic wrapper types?

I’ve created a generic wrapper type (AnimalVehicleWrapper in the example below). I’ve created two separate derived types, one which holds “parent” types (animal and vehicle) and one that holds more derived types (dog and car). I’m wondering if it’s possible to create a type hierarchy such that I could create a method that would define an incoming ParentWrapper parameter, which would all me to pass either that type OR the more derived DerivedWrapper.