Maybe I live in a bubble, or am just too new, but I was wondering if anyone else has noticed the heavy use of 'var' to declare variables instead of a specific type in many of the MVC examples by Microsoft? Is there a purpose for this, or is it the "in" thing to do now, or just personal style?
4 Answers
Jared Parsons talked about this in his blog I don't agree with his conclusions (as my comment there indicates), but this article should explain why it's used so much.

- 16,475
- 2
- 44
- 51
-
Link is dead now. – TSB99X Apr 19 '20 at 14:11
All MVC Videos are maded in speedy way(also not always they using Unit test or placing bussiness logic in controlers). This is not because they are bad programmers, or "var" is cool, but because they want to quickly show some cool new features, and typing full name twice is not what they want to show.

- 1,475
- 4
- 18
- 33
The answer I gave below (in italics) is incorrect but as I would assume it is an assumption that a lot of people will make I am leaving it in. For a explanation on why it is wrong read:
WRONG ANSWER: Personally I think that var has a bad name due to it's poor use in languages like Visual Basic and Excel Basic. At the end of the day everything in .NET is derived from object which is basically the same as declaring something as var.

- 897
- 1
- 15
- 24
-
Not exactly. A "var" variable is still strongly-typed to its *actual* type, the system just figures it out instead of making you type it out explicitly. This is not the same concept as a Variant, or passing stuff around as an "object". – GalacticCowboy Dec 03 '08 at 00:38
-
I understand that people have every right to mark an answer down but I am just wondering what benefit it is in this case. I made a mistake, acknowledged it and post a link to a correct explanation. I understand now why users simply won't post anymore for fear of the scorn of 'Gurus' – Skittles Dec 04 '08 at 00:43
-
@Skittles: the point of downvoting is so that incorrect or poor answers are readily recognizable as such. If the best answer, for whatever reason, only gets 1 up vote, and all the others are at 0, then it's hard to say that any of the others are really bad. Down votes help clarify that. – Harper Shelby Dec 05 '08 at 21:07
-
@Harper: Thanks you for taking the time to explain. I will update the answer that I gave to reflect this. – Skittles Dec 08 '08 at 22:51