Hi All,
I am really confused as to how the instance method calls on the value types are processed. My initial understanding was that since value types do not have an object header associated with them as compared to reference types, for all instance method calls on the value type the value type instance will be boxed. Soon i realized that i am wrong!!
For example, for the following simple code
using System;
class A { static void Main() {
int i;
i = 0; Console.WriteLine(i.ToString());
Console.ReadLine();
}}
looking at the IL it is clear that it is not boxing the value type instance
Here's the IL code...
.method private hidebysig static void Main() cil managed
{
.entrypoint
// Code size 21 (0x15)
.maxstack 1
.locals init (int32 V_0)
IL_0000: ldc.i4.0 // Push 0 onto the stack as int32
IL_0001: stloc.0 // Pop value from stack into local
variable 0
IL_0002: ldloca.s V_0 // Load local variable address on to the
stack
IL_0004: call instance string [mscorlib]System.Int32::ToString()
IL_0009: call void [mscorlib]System.Console::WriteLine(string)
IL_000e: call string [mscorlib]System.Console::ReadLine()
IL_0013: pop
IL_0014: ret
} // end of method A::MainThose comments are added by me (In an attempt to understand it). I think I am missing a lot of things on the basics!
If someone can elaborate more on that then it would be of great help
Thanks in advance
Regards, Girish Jain
_________________________________________________________________ NRIs - Free money transfer to India. Fly to India for free! http://acm.bridgeovertw.com/hdfc/qr/landingpage/sep04/index.htm?sitecode=610|394 Apply Now.
=================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in:
Essential .NET: building applications and components with C# November 29 - December 3, in Los Angeles http://www.develop.com/courses/edotnet
View archives and manage your subscription(s) at http://discuss.develop.com
