- An object
- will be determined at runtime, but var is defined at compile time.
eg:
var i = 2; object j = 2;
and you look at it in ildasm:
IL_0000: nop IL_0001: ldc.i4.2 IL_0002: stloc.0 IL_0003: ldc.i4.2 IL_0004: box [mscorlib]System.Int32 IL_0009: stloc.1
You can see that the object should be placed in the box, and the var element is not needed for the box.
MSDN for object and var
source share