Force calling the base method from outside a derived class

前端 未结 7 910
野性不改
野性不改 2020-12-10 18:56

I have two classes:

public class MyBase
{
    public virtual void DoMe()
    {

    }
}

public class MyDerived:MyBase
{
    public override void DoMe()
             


        
相关标签:
7条回答
  • 2020-12-10 19:36

    The derived class does not need to provide an implementation of the method. Remove it and the implementation in the base class will be called by default.

    If, unlike your example, the method in the base class is abstract and you must provide an implementation but it doesn't make sense for the derived class to provide one then there is probably something wrong with the design of the classes.

    0 讨论(0)
提交回复
热议问题