I want to do the exactly the same thing described here, but in C#.
public interface IFoo { void DoSomething(); }
public class Foo : IFoo
{
public void DoSomething() {...}
protected void Bar() {...}
}
public class Foo2 : IFoo
{
private readonly Foo _foo;
public Foo2 (Foo foo) { _foo = foo; }
public void DoSomething() {...}
protected void Bar()
{
_foo.Bar(); // cannot access Bar() from here
}
}
I looked at several similar questions, but none of them really tell you exactly how to solve this problem. Is trying to decorate a class with protected method a wrong thing to do in the first place?