Click here to Skip to main content
15,882,017 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Can the C# ‘var’ keyword be misused?

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
10 Jul 2011CPOL1 min read 5.9K  
I've always used var because ReSharper suggested it by default. However, like most people, I only did this when I didn't understand the conotations of ReSharper's suggestion. Now I disable this suggestion in the plug-in, and in actual fact, I prefer to use the fully qualified name on at least...

I've always used var because ReSharper suggested it by default. However, like most people, I only did this when I didn't understand the conotations of ReSharper's suggestion. Now I disable this suggestion in the plug-in, and in actual fact, I prefer to use the fully qualified name on at least one side of the operand. This still means I use var occasionally.


Having used StyleCop in a few of the places I've worked, I came to the conclusion that it does not matter what style of language you use, whether you use var or not - so long as you and your team all agree to that style for the project.


The only thing that truly makes code unmaintainable is inflexible developers who cannot accept that there's is not the only way in the world. Better to learn to just reach a consensus with the rest of the team.


We agree on the maximum amount of whitespace, whether the using statement should be inside the namespace declaration or outside (as default). We also choose whether to add a signature to our classes (making it easier to ask questions about a potentially unmaintainable class - and many other things.


In the long run though - little issues like this are less important than achieving working deliverables.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Crantech Solutions Ltd
England England
This member doesn't quite have enough reputation to be able to display their biography and homepage.

Comments and Discussions

 
-- There are no messages in this forum --