This is an example of boxing and unboxing:
http://msdn.microsoft.com/en-us/library/yz2be5wk (VS.80) .aspx
C # takes an int value type (maybe it's a local variable, in a register or on a stack), boxing it in an object and putting it in a heap. When you return to int, the process reverses.
More generally, the compiler creates a rather complex and specific type of IL during casting, in particular, it must make sure that at run time the types that you execute are compatible, look for specific casting operators defined in your code, handle overflows and etc. Casting is a rather expensive process.
James gaunt
source share