Now Repeat After Me, Var Isn't an Object

Leave it to Ian to cut through the crap and give a very clear and detailed account of what exactly the new var keyword in C# does.

When reading through blogs, mailing lists, and newsgroups, you can encounter a lot of noise from people who are just looking for something to rant about without actually taking the time to understand what they’re talking about. This can be about the most annoying thing in the world.

So if you caught yourself asking:

What’s wrong with "Object"?

I encourage you to read Ian’s post.

What others have said

Requesting Gravatar... Sharp as a Marble Sep 23, 2005 11:09 AM
# re: Now Repeat After Me, Var Isn't an Object
Smells a lot like 'variant' in good ol' ASP.

I wonder if it has the same overhead as variant did?
Requesting Gravatar... Haacked Sep 23, 2005 1:58 PM
# re: Now Repeat After Me, Var Isn't an Object
Heh heh.. you're busting my chops.

If you read the article, you'll notice that the var keyword is statically typed using type inference. In otherwords, it's compile time evaluated. In other words, there is no overhead.
Requesting Gravatar... Niels Hansen Sep 23, 2005 2:48 PM
# re: Now Repeat After Me, Var Isn't an Object
Think of it more like the Dim statment in Visual Basic

Why should you have to tell the compiler twice what the variable is. The compiler should be smart enough to know what your asking.

Requesting Gravatar... Haacked Sep 23, 2005 3:27 PM
# re: Now Repeat After Me, Var Isn't an Object
Excellent point!

What do you have to say?

(will show your gravatar)
Please add 4 and 3 and type the answer here: