C
C#2mo ago
alex

Using 'var' instead of explicitly stating the type

JetBrains Rider suggests I change CircleData[] circles = CircleRegistry.ToDataArray(); to var circles = CircleRegistry.ToDataArray(); with the warning:
Use 'var' (elsewhere)
I understand this is just coding style, but is it considered standard practice to use var whenever possible in C#? As someone with a bit of C++ experience this feels weird to me
4 Replies
reflectronic
reflectronic2mo ago
well, one could call it contentious but many C# developers use var in all possible cases, yes
alex
alexOP2mo ago
do you know why? or is it just how it is in many style guides
reflectronic
reflectronic2mo ago
because it is shorter and easier to type
alex
alexOP2mo ago
okay, thanks for the help C# style seems so strange sometimes

Did you find this page helpful?