Method can be made static, but should it?

后端 未结 14 1216
说谎
说谎 2020-11-22 17:16

Resharper likes to point out multiple functions per asp.net page that could be made static. Does it help me if I do make them static? Should I make them static and move them

14条回答
  •  耶瑟儿~
    2020-11-22 17:37

    Marking a method as static within a class makes it obvious that it doesn't use any instance members, which can be helpful to know when skimming through the code.

    You don't necessarily have to move it to another class unless it's meant to be shared by another class that's just as closely associated, concept-wise.

提交回复
热议问题