Re: Struct inside class

Tech-Archive recommends: Fix windows errors by optimizing your registry



WOW! It's just amazing answer, almost little article. :) Great thanks
for it!

Michael D. Ober wrote:

It is relative to the value in register DS, which is set at
application startup by the memory manager. As you should be able to
see from the assembler code, there is no "boxing" of the variables.
Boxing requires a rather expensive call to determine an object's
actual data type.

Yes, you absolutely right - up to this point no any boxing. But my
second question was:
......
myClass.s.i1 = 999;
myClass.s.i2 = 888;
object o = myClass.s.i1; //<< is boxing _here_?
Now I am sure - it IS. I see it in Reflector:
......
L_001d: ldc.i4 888
L_0022: stfld int32 _111_.S::i2
L_0027: ldloc.0
L_0028: ldflda _111_.S _111_.C::s
L_002d: ldfld int32 _111_.S::i1
L_0032: _box int32_
L_0037: stloc.1
......
So - in spite of the fact that i1 already in heap it can not be stored
in the variable o, so boxing it is inevitable.
.



Relevant Pages

  • Re: Struct inside class
    ... I missed the second question as I couldn't get a clean download until this ... boxing requires ... additional code and an additional call into the memory manager. ...
    (microsoft.public.dotnet.framework)
  • Re: Struct inside class
    ... Michael D. Ober wrote: ... information to generate the metadata required by the boxing. ... If replying to the group, please do not mail me too ...
    (microsoft.public.dotnet.framework)