Is using “base” bad practice even though it might be good for readability?

前端 未结 5 1620
野性不改
野性不改 2021-01-11 13:24

I know this is a subjective question, but I\'m always curious about best-practices in coding style. ReSharper 4.5 is giving me a warning for the keyword \"base\" before bas

5条回答
  •  星月不相逢
    2021-01-11 13:37

    I am not really sure using this is a bad practice or not. base, however is not a matter of good or bad practice, but a matter of semantics. Whereas this is polymorphic, meaning that even if the method using it belongs to a base class, it will use the overriden method, base is not. base will always refer to the method defined at the base class of the method calling it, hence it is not polymorphic. This is a huge semantic difference. base should then be used accordingly. If you want that method, use base. If you want the call to remain polymorphic, don't use base.

提交回复
热议问题