C# - Do you use "var"?
- by Paul Stovell
C# 3.0 introduces implicitly typed variables, aka the "var" keyword.
var daysInAWeek = 7;
var paul = FindPerson("Paul");
var result = null as IPerson;
Others have asked about what it does or what the problems with it are:
http://stackoverflow.com/questions/527685/anonymous-types-vs-local-variables-when-should-one-be-used
http://stackoverflow.com/questions/209199/whats-the-point-of-the-var-keyword
http://stackoverflow.com/questions/41479/use-of-var-keyword-in-c
I am interested in some numbers - do you use it? If so, how do you use it?
I never use var (and I never use anonymous types)
I only use var for anonymous types
I only use var where the type is obvious
I use var all the time!