Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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:

Var is Not Object

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.

All of the above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top