J
Jacob
Hi All,
My C# book says that this code
string s = 10.ToString();
will box the literal 10 to an object (i.e. allocate a temporary class on the
heap). However, if I view this in assembly view (vs2005) I get something
like this:
int i = 5;
00000057 mov dword ptr [ebp-40h],5
string s1 = i.ToString();
0000005e lea ecx,[ebp-40h]
00000061 call 786FD550
00000066 mov esi,eax
00000068 mov dword ptr [ebp-44h],esi
string s2 = 6.ToString();
0000006b mov dword ptr [ebp-68h],6
00000072 lea ecx,[ebp-68h]
00000075 call 786FD550
0000007a mov esi,eax
0000007c mov dword ptr [ebp-48h],esi
I don't see any allocation in here at all. The literal 6 conversion seems to
look exactly like the int conversion that I put in for comparison. Where is
the boxing allocation happening? What am I missing?
My C# book says that this code
string s = 10.ToString();
will box the literal 10 to an object (i.e. allocate a temporary class on the
heap). However, if I view this in assembly view (vs2005) I get something
like this:
int i = 5;
00000057 mov dword ptr [ebp-40h],5
string s1 = i.ToString();
0000005e lea ecx,[ebp-40h]
00000061 call 786FD550
00000066 mov esi,eax
00000068 mov dword ptr [ebp-44h],esi
string s2 = 6.ToString();
0000006b mov dword ptr [ebp-68h],6
00000072 lea ecx,[ebp-68h]
00000075 call 786FD550
0000007a mov esi,eax
0000007c mov dword ptr [ebp-48h],esi
I don't see any allocation in here at all. The literal 6 conversion seems to
look exactly like the int conversion that I put in for comparison. Where is
the boxing allocation happening? What am I missing?