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

前端 未结 5 1618
野性不改
野性不改 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:44

    The only time you should use base.MethodCall(); is when you have an overridden method of the same name in the child class, but you actually want to call the method in the parent.

    For all other cases, just use MethodCall();.

    Keywords like this and base do not make the code more readable and should be avoided for all cases unless they are necessary--such as in the case I described above.

提交回复
热议问题