Var or implicit type? #507
Closed
GeorgeLeithead
started this conversation in
General
Replies: 3 comments
-
Any thoughts, opinions, ideas? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I would recommend something like this: var myClass = new MyClass(); // use var if the type is clear
MyClass myClass = new(); // alternative variant
var myString = GetMyString(); // type is clear -> use var
MyClass myClass = GetCalculationResult(); // type not clear -> do not use var |
Beta Was this translation helpful? Give feedback.
0 replies
-
Closed as answered |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I personally prefer using implicit types. However, whislt contributing and receiving contributions from other (great) contributors, I noticed that SOME change the code to use
var
rather than implicit types. Should the CONTRIBUTING.md specify var or implicit types, and could this be enforced by.editorconfig
or `StyleCop.Analyzers'?Beta Was this translation helpful? Give feedback.
All reactions