Today: what do we mean by “covariance” and “contravariance”? The first thing to understand is that for any two types T and U, exactly one of the following statements is true: T is bigger than U. T is smaller than U. T is equal to U. T is not related to U. For example, consider a type hierarchy consisting of Animal, Mammal, Reptile, Giraffe, Tiger, Snake and Turtle, with the obvious relationships. ( Mammal is a subclass of Animal, etc.) Mammal is a bigger type than Giraffe and smaller thanAnimal, and obviously equal to Mammal. But Mammal is neither bigger than, smaller than, nor equal to Reptile, it’s just different. Why is this relevant? Suppose you have a variable, that is, a storage location. Storage locations in C# all have a type associated with them. At runtime you can store...
C#, OOPS, MVC, WCF, Architecture, SQL, Table, Triggers, Script and SQL Server