Re: Struct inside class
- From: "Sneil" <at@xxxxxxx>
- Date: Wed, 31 May 2006 12:57:28 -0700
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_0037: stloc.1L_0032: _box int32_
......
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.
.
- References:
- Struct inside class
- From: Sneil
- Re: Struct inside class
- From: Barry Kelly
- Re: Struct inside class
- From: Sneil
- Re: Struct inside class
- From: Göran Andersson
- Re: Struct inside class
- From: Jon Skeet [C# MVP]
- Re: Struct inside class
- From: Göran Andersson
- Re: Struct inside class
- From: Michael D. Ober
- Struct inside class
- Prev by Date: Re: Empty Interface in VB?
- Next by Date: Re: .Net Framework2 question
- Previous by thread: Re: Struct inside class
- Next by thread: Re: Struct inside class
- Index(es):
Relevant Pages
|