Why the concept of "Covariance" and "Contravariance" are applicable while implementing the methods o

Posted by Amy on Stack Overflow See other posts from Stack Overflow or by Amy
Published on 2010-03-23T17:41:28Z Indexed on 2010/03/23 17:43 UTC
Read the original article Hit count: 444

Filed under:
|

The use case is some what like this:

public class SomeClass: IClonable
 {
     // Some Code

     //Implementing interface method
     Public object Clone()
      {
        //Some Clonning Code
      }
 }

Now my question is "Why is it not possible to use "SomeClass(As it is derivd from objec)" as a return type of Clone() method if we consider the Funda's of Covariance and Contravariance.

Can somebody explain me the reason behind this implemementaion of Microsoft ????

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET