usage of var everywhere considered harmful

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
I've seen that v1.5 uses var in a lot of places compared to v1.4. I don't know if this is because tools like ReSharper show them like if it was better to convert everything that's possible to var and it points it out like a code smell but this is what the C# reference tells about var:

"Overuse of var can make source code less readable for others. It is recommended to use var only when it is necessary, that is, when the variable will be used to store an anonymous type or a collection of anonymous types."

I know there can be all kinds of opinions about the var usage, but I'm on the side that it makes the code less readable.
13 years ago
It all depends what's on the right hand side. If the right hand side is a simple constructor call the code is just as or more readable than before. If you need to move your mouse over the code to see what the var underlying type will be it's less clear and not a good thing. Imho.
13 years ago
Now I'm getting deeper into the code I have to agree with you, the indiscriminate use of "var" is ghastly. As often as not it's not clear what the type is without moving the mouse over.
13 years ago
you guys are absolutely right. it is a Resharpner suggestion and it puts it everywhere without rules. i have stopped using Resharpner for code inspection. the VS code anlyis tools are quiet solid and more realistic.

thanks.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.