templating icon indicating copy to clipboard operation
templating copied to clipboard

what the policy on var?

Open SimonCropp opened this issue 1 year ago • 1 comments
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 image

places where target typed new is used instead of var

TokenTrie trie = new();

So what is the preference?

SimonCropp avatar Jun 17 '24 23:06 SimonCropp

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

SimonCropp avatar Jun 17 '24 23:06 SimonCropp