C # Secure Method Implementation Interface

I have class / interface definitions in C #

public class FooBase {
    ...
    protected bool Bar() { ... }
    ...
}

public interface IBar {
    bool Bar();
}

Now I want to create a class Foo1 derived from FooBase that implements IBar:

public class Foo1 : FooBase, IBar {
}

Is there any class declaration mask that the compiler uses the inherited protected method as a public implementation of the interface?

Of course method foo1

bool IBar.Bar()
{
    return base.Bar();
}

working. I'm just wondering if there is a shortcut;)

Omitting this method leads to a compiler error: Foo1 does not implement the IBar.Bar () interface member. FooBase.Bar () is either static, not public, or has the wrong return type.

Explanation: I separate code inheritance (class hierarchy) and function implementation (interfaces). Thus, for classes that implement the same interface, access to a common (inherited) code is very convenient.

+3
3

. , , ( ICollection, ):

public class Foo : ICollection
{
    protected abstract int Count
    {
        get;
    }

    int ICollection.Count
    {
        get
        {
            return Count;
        }
    }
}
+4

, . , - .

+1

FooBase.Bar() IBar. ().

. .

. , Foo IBar.

bool IBar.Bar() 
{
    return base.Bar();
}

Bar() - .

, ( , ).

new public bool Bar() 
{
    return base.Bar();
}

, .

+1
source

Source: https://habr.com/ru/post/1714676/