varget about it
March 26th, 2008
I have heard a lot of debates lately about the usage of var within a code base. I for one am a var convart, I love it, use it all ovar…. var var var.
Some common complaints I hear:
Makes the code hard to read
It’s not the var that is making it hard to read my friend.
Should only be used for anonymous types
Bah, says who? The compiler?
Its like variant in VB, Ill lose my type safety
Nope, its the real type, we just don’t have to worry about it.
There are many benefits, as pointed out in this great post from Ilya Ryzhenkov (Resharper) .
I’m sure its preference more than anything, I want to use it, and it works great for me. Likely there are many who disagree, and hopefully I wont change my mind next week.
What do you think?


