I've been away from inheritance for a while and need a little helping hand.
I have an abstract base class Chief
. There are two inheriting classes Ship
and Vehicle
, which share several properties via Chief
.
I have a method which uses those common properties:
public static void AssignRandomProperties(PSetList routeSettings, List<Chief> theChiefs)
but when I try to pass a
List<Ship>
or a
List<Vehicle>
I'm told that they can't be converted. Here's a sample method call:
ChiefRouteRandomizer.AssignRandomProperties(s.Route, theVehicles);
I was assuming of course that the List<Vehicle>
would be treated as a List<Chief>
when passed as the argument to AssignRandomProperties
, but apparently not. Does the list need converting to List<Chief>
first? If so, how?