Комментарии:
Very useful with foreach loops and LINQ queries. Use it all the time. But in other scenarios it's better to stick to explicit typing.
ОтветитьGood video! I would add that it's good practice to only use var when there's a (visually) explicit declaration on the right hand side. For example, doing var myvar = myObscureMethod() makes the return type unnecessarily ambiguous, so in this case strict typing makes more sense, but for something that's unnecessarily verbose it can clean it up quite well, something like var myvar = new SpecificVerboseType() and the type is still visually determinable
Ответить