Take the classes in the last post (First, Second, Third) and assume they are exactly the same in this example. In Covariance, we learned that whatever variable to you set equal to the return of a method has to be equal in type of larger. Or in other words, it has to have equal or [...]
Tag Archives: Covariance
Covariance versus Contravariance
Ok so I stumbled on to this subject the other day and thought it was worth noting. Take these simple classes: public class First { public String FirstOutput { get; set; } } public class Second : First { public String SecondOutput { get; set; } } public class Third : Second { public String [...]