Why ReSharper always suggests to "use var" instead of explicit type usages? Follow
You may read about it ReSharper Code Inspection Wiki; This suggestion is turned on by default.
You can disable this suggestion through "ReSharper | Options | Code Inspection | Inspection Severity":
Please sign in to leave a comment.
As a corollary, I'd really like to enable using the "var" keyword for extracted variables by default. Resharper used to do this before my machine was reloaded -- now I can't seem to find the setting (or help on the net) to re-enable it. To be clear: this isn't to do with the warning insomuch as that, when I press ctrl-r, v, I want to get code like "var someVariableName = <extracted result>"
@Davyd, by default, ReSharper is asking if you'd like to use var or explicit type when introducing variable (see screenshot). You need to have ReSharper IntelliSense enabled for it in the options, though (ReSharper | Options | IntelliSense | General).
Thanks, I see that Resharper is remembering my last choice -- I just don't remember it even asking in the past (and, personally, I'd prefer it not to). I could be well wrong about whether or not it was asking -- but I still maintain that I'd prefer it not to ask at all as I'd always like to use var and it's just one extra confirmation I have to go through (:
This entry simply does not exist in ReShaper 9. How can I disable this annoying shit?
Looks like they expanded it out into further options
I used to have it configured like this (use var only when type is explicit), but in Resharper 9 this setting is gone. How do you get the same behaviour in version 9?
@Francesc Castells, please try settings in ReSharper | Options | Code Editing | C# | Code Style | 'var' usage in declarations.
I don't know the rational behind this suggestion/rule. Can somebody explain to me why you would want to do this -- set variable to var.
This article is out of date. Please update it to reflect the current resharper options.