No, It is Immpossible.
So, if we have a function that accepts List<Car> types. Clearly, this feature should be able to add the Prius to this list, no? Well, if you were allowed to pass a List<Mustang> this method, you would just add a Prius to the List<Mustang> , which would be bad.
Now, if instead of passing a List , the method had an IEnumerable parameter or one of some other read-only collection types, then it could be "covariant." In this case, you can take IEnumerable<Car> as an example and pass it List<Mustang> , because you never add to the list, you only get access to various elements and as long as all Mustang objects are Car objects, which not a problem.
The design also seems a bit ... off. I don't think Ford should inherit from Car . Ford is not a car, it is a brand, a company, a type of car. Mustang is a car , so it makes sense to inherit it. I would create a new type, say Manufacturer , from which you could create Ford , Toyota , etc. And make this property (read-only) Car .
Servy source share