I use var for nearly every assignment to a local variable. This really limits the amount of code changes I have to make if a particular method's return type changes. For example, if I have the following method:
List<T> GetList()
{
return myList;
}
I could have lines of code all over the place doing local variable assignment that looks like this:
List<T> list = GetList();
If I change GetList() to return an IList<T> instead, then I have to change all those lines of assignment. N lines of assignment equals N+1 code changes if I change the return type.
IList<T> GetList()
{
return myList;
}
If, instead, I had coded like the following:
var list = GetList();
Then I only have to change GetList() and the rest will be verified through compilation. We're off and running with only one code change. Granted, the compiler will complain if there was code depending on list to be a List<T> and not an IList<T>; but those should be fewer than N.