Why should the following not compile? ( it does not)

interface ISomething
{

Apples a {get;set;}
}


public class ChilieanApples:Apples
{
}

public class Apples
{
}


Class SomethingSpecific:ISomething
{
public ChilieanApples apples {get;set;}
}

Re: inherited class instead of expected class in interface by Jon

Jon
Fri May 09 08:38:42 CDT 2008

On May 9, 2:21 pm, parez <psaw...@gmail.com> wrote:
> Why should the following not compile? ( it does not)

Because C# doesn't support covariance of return types in terms for
interface implementation and member overriding. To override/implement
something, you have to supply exactly the same signature.

It's a pain, but that's the way it is.

Jon

Re: inherited class instead of expected class in interface by parez

parez
Fri May 09 10:26:59 CDT 2008

On May 9, 9:38 am, "Jon Skeet [C# MVP]" <sk...@pobox.com> wrote:
> On May 9, 2:21 pm, parez <psaw...@gmail.com> wrote:
>
> > Why should the following not compile? ( it does not)
>
> Because C# doesn't support covariance of return types in terms for
> interface implementation and member overriding. To override/implement
> something, you have to supply exactly the same signature.
>
> It's a pain, but that's the way it is.
>
> Jon

Thanks.
I thought I mite have missed something because i expected it to
compile.