Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

inherited class instead of expected class in interface implementation

0 views
Skip to first unread message

parez

unread,
May 9, 2008, 9:21:29 AM5/9/08
to
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;}
}


Jon Skeet [C# MVP]

unread,
May 9, 2008, 9:38:42 AM5/9/08
to
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

parez

unread,
May 9, 2008, 11:26:59 AM5/9/08
to

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

0 new messages