.NET C# Explicit implementation of grandparent's interface method in the parent interface

Posted by Cristi Diaconescu on Stack Overflow See other posts from Stack Overflow or by Cristi Diaconescu
Published on 2010-12-21T16:17:57Z Indexed on 2010/12/21 16:54 UTC
Read the original article Hit count: 273

That title's a mouthful, isn't it?...

Here's what I'm trying to do:

public interface IBar {
     void Bar();
}
public interface IFoo: IBar {
    void Foo();
}
public class FooImpl: IFoo {
    void IFoo.Foo()   { /*works as expected*/ }
    //void IFoo.Bar() { /*i'd like to do this, but it doesn't compile*/ }
    void IBar.Bar()   { /*works as expected*/ }
}

So... Is there a way to declare IFoo.Bar(){...} in my class, other than basically merging the two interfaces into one?

And, if not, why?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET