templating
templating copied to clipboard
what the policy on var?
trafficstars
currently there are
places where type is apparent where var is not use
List<IOperationConfig> operationConfigReaders = new List<IOperationConfig>(componentManager.OfType<IOperationConfig>());
places where type is apparent where var is used
var process = new Process()
places where type is not apparent where var is used
var installer = installerFactory.CreateInstaller(settings, packagesFolder);
which also produce a warning
places where target typed new is used instead of var
TokenTrie trie = new();
So what is the preference?
for the record my preference is to always use var. It is easy to consistently apply and reason about when writing code. And for the several years that i have been applying this (on the approx 100 projects i actively contribute to) i have never had a case where the code was confusing to read/understand as a result of using var