When I first got hold of VS2008, and had a play with the new version of C# I loved the Var keyword. To me the most amazing thing was no more declarations like this:
Instead I could write the following:
Making it akin to VB developers being able to write:
(I have had however to cope with a coding standard that explicitly forbid this declaration in VB...Backwards or what?)
My only gripe with the var keyword is that it is being overused. Horribly. Every day I come across people (mainly on StackOverflow, but development blogs, people I know do this too) writing code something like this:
In that code snippet there is one place where var is used well. Don't declare strings as var, it's a string. Don't declare int as var, not only is it not necessary, it hasn't saved you any typing, they are both 3 characters long.
The other point (one I seem to keep coming back to) is code readability:
Now, what is the type of result? Admittedly, this could be improved by naming your functions properly and naming variables a little less generically, like so: