Use implicitly typed local variable declaration
Why does resharper4 keep telling me:
"Use implicitly typed local variable declaration"
I can see I might want to go:
foreach(var myThing in object[])
but I don't understand why I would want to replace:
MyConfigObject configs = .... with var configs = ....
Please sign in to leave a comment.
Hi,
I am also awaiting an answer for this refactoring. We think it is also not a good idea. Please enlighten us as to the reason behind this.
Thanks
SurfRat.
Ilya blogged about this a while ago:
http://resharper.blogspot.com/2008/03/varification-using-implicitly-typed.html
Which was then discussed on InfoQ:
http://www.infoq.com/news/2008/05/CSharp-var
I am in favor of using var just because it is less characters.
This is going to be one of those theological debates like you have many in
the IT world in the same style as "my editor is better than yours". You
either like it or you don't. Personally I don't think that it makes the code
harder to read although people say that it does. It does get a while to get
used to but once you are used to it you will prefer it over explicity
specifying the type.
Cheers
Gabriel Lozano-Moran
"Surf" <no_reply@jetbrains.com> wrote in message
news:14701071.27621213352913486.JavaMail.jive@app4.labs.intellij.net...
>
>
If you don't like the suggestion, you can turn it off.
"Simon" <no_reply@jetbrains.com> wrote in message
news:26837045.23621213262955079.JavaMail.jive@app4.labs.intellij.net...
>
>
Thanks for the response - answered my question.