I think that C# newbie List<Interface>
questionC# newbie List<Interface>
question is a duplicate, but not a duplicate of Why is this cast not possible?Why is this cast not possible?.
They are both "why doesn't variance work the way I'd like it to work in C#" duplicates. However, "newbie" is so much simpler that, if it were not a duplicate of many others, it would deserve to stand on its own.
The problem will be finding the other duplicates. The following are from the first page of http://stackoverflow.com/search?q=contravariance+interface+c%23+list+generichttps://stackoverflow.com/search?q=contravariance+interface+c%23+list+generic. There are ten pages:
- In C#, why can't a List<string> object be stored in a List<object> variableIn C#, why can't a List<string> object be stored in a List<object> variable
- Why can't List<parent> = List<child>?Why can't List<parent> = List<child>?
- How to make a generic class with inheritance?How to make a generic class with inheritance? (EL)
- C# : Is Variance (Covariance / Contravariance) another word for Polymorphism?C# : Is Variance (Covariance / Contravariance) another word for Polymorphism?
- Upcasting and generic listsUpcasting and generic lists
BTW, I chose "contravariance" in the above search because I thought there would be fewer occurrences of that word than of "covariance". There were ten pages of each.