Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what the policy on var? #8133

Open
SimonCropp opened this issue Jun 17, 2024 · 1 comment
Open

what the policy on var? #8133

SimonCropp opened this issue Jun 17, 2024 · 1 comment

Comments

@SimonCropp
Copy link
Contributor

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant