Interesting discussion. I found var
a bit difficult to cope with at first as it does hide the actual type. Fortunately many IDEs will, as has been pointed out elsewhere, give you the type if you hover over the 'var
'. This, however, doesn't help when dealing with printed/quoted code snippets or when working in an environment that doesn't reveal the type. So, my definition of 'appropriate' is where the type is obvious (usually because the assignment includes the type as part of a 'new
' or a typecast of some kind) or because the type is so complicated that it obfuscates itself (e.g. nested generics with multiple parameters). In the latter case I either rely on VS for an explanation or, where possible, simplify the type by creating a new wrapper class
/struct
with XML help to explain what the class is about. The basic rule is "Think about other people when writing your code." Always ask yourself 'Can this be understood without having to look through reams of code or relying on an IDE to find variable/type definitions?' If not can it be simplified or explained?" If all else fails use a comment to explain (and thereby starts another argument :sigh: ).