Re: Struct inside class

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Sneil wrote:
Barry Kelly wrote:

The memory for the struct s in this example is part of (i.e. fully
contained within) the heap-allocated object myClass.

OK, I think the same. BUT! In other words myClass.s.i1 is already in
heap, yes? Now - what is boxing? Boxing is creating special packed
version of value-type in heap. In our case i1 ALREADY in heap. So...
object o = myClass.s.i1; //_not_ a boxing here?
???

Yes, it's boxed. You are not storing the myClass.s.il variable in the object, you are storing a copy of the value of the myClass.s.il variable.
.



Relevant Pages

  • Re: Struct inside class
    ... Boxing is creating special packed ... version of value-type in heap. ... you are storing a copy of the value of the myClass.s.il variable. ...
    (microsoft.public.dotnet.framework)
  • Re: Struct inside class
    ... contained within) the heap-allocated object myClass. ... Boxing is creating special packed ... version of value-type in heap. ...
    (microsoft.public.dotnet.framework)
  • Re: Struct inside class
    ... In this case, boxing must be done. ... that the compiler will have to generate addition calls into the memory ... so it's stored on the heap. ... If GC_ALLOCATE can't allocate the requested ...
    (microsoft.public.dotnet.framework)
  • Boxing effect on struct methods
    ... Couple of questions relating to boxing. ... the heap so that the system can treat a value type like a reference type. ... If I add custom instance method on a struct, will it box that type each ...
    (microsoft.public.dotnet.languages.csharp)
  • Boxing questions relating to struct methods
    ... Couple of questions relating to boxing. ... the heap so that the system can treat a value type like a reference type. ... If I add custom instance method on a struct, will it box that type each ...
    (microsoft.public.dotnet.framework)