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

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

    Another important point to take into consideration is that while you haven't currently overridden that method that doesn't mean you won't ever in the future and by prefacing all of your calls with base. you won't get the new functionality without performing a find and replace for all your calls.

    While prefacing calls with this. will not do anything other than decrease / increase readability (ignoring the situation where two variables in scope have the same name) the base. prefix will change the functionality of the code you write in many common scenarios. So I would never add base. unless it is needed.

提交回复
热议问题