Resharper: vars

后端 未结 8 2090
闹比i
闹比i 2020-12-01 10:52

Why does Resharper want you to change most variables to var type instead of the actual type in the code?

相关标签:
8条回答
  • 2020-12-01 11:40

    I saw a video from Hadi Hariri, where he was presenting Resharper 6.x. His reasoning was, if you are forcing a user to use "var", you are actually forcing him to name the variable in a more meaningful way, that way all the names are readable and make more sense.

    0 讨论(0)
  • 2020-12-01 11:43

    To answer your question ... because someone at JetBrains decided that was the "preferred" way.

    To change it follow Jon's answer. Additionally you can also change ReSharper's behavior when doing Code Cleanup (which I use a lot) under the Code Cleanup section in ReSharper options. Set to "Use Explicit Type".

    0 讨论(0)
提交回复
热议问题