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
.
Returning “this” in Method with Generic Return Type
I’m writing generic methods and I am confused as to why the following code snippet throws a syntax error: