It. against the base. for inherited protected non-virtual methods?

In my subclass, should I refer to an inherited protected non-virtual method like this.Method() or base.Method() ?

Using this will allow me to easily hide a method using a new method with the same name. Should method calls explicitly indicate base only when it is certain that you only need to call the base class implementation?

+7
source share
2 answers

Call always with this.Method() .

If you hide a method, you probably want to call a new method, not one that is in the base class. On the other hand, if you make the method of the base class virtual, you probably want your code to be called, if in a polymorphic way.

It is difficult to predict the future, but these scenarios are likely to happen.

+2
source

If you ever want to add a member named Method to your subclass and still want to call an inherited method, you should use base.Method() . Adding members named Method to more derived classes will not change the value of the this.Method() call.

+7
source

All Articles