C# in Depth

Cover of C# in Depth
Order now (3rd edition)

"var" isn't "variant" - "object" is!

Chapter 8: Cutting fluff with a smart compiler: 8.2.1

Created: 3/3/2008
Last updated: 3/3/2008

I go to great lengths in the book to explain that the use of implicitly typed local variables (var) isn't the same as making the code dynamically typed, or introducing the Variant type from COM or VB6. However, we already have something approaching that - object! If you declare a variable as being of type object, you can store whatever you like in it. That's not true of implicitly typed variables.