C
C#3h 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
reflectronic3h ago
well, one could call it contentious but many C# developers use var in all possible cases, yes
alex
alexOP3h ago
do you know why? or is it just how it is in many style guides
reflectronic
reflectronic3h ago
because it is shorter and easier to type
alex
alexOP2h ago
okay, thanks for the help C# style seems so strange sometimes

Did you find this page helpful?