C#: Any way to skip over one of the base calls in polymorphism?

后端 未结 7 1410
一个人的身影
一个人的身影 2021-01-17 16:34
class GrandParent
{
    public virtual void Foo() { ... }
}

class Parent : GrandParent
{
    public override void Foo()
    {
       base.Foo();

       //Do additi         


        
7条回答
  •  孤独总比滥情好
    2021-01-17 17:01

    If you have control of the code, the simplest way is to create a protected method in Parent class that only call base.Foo() and your child class Foo implementation call that method explicitly

提交回复
热议问题