Re: Struct inside class

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



"Sneil" <at@xxxxxxx> wrote:

Example:
namespace _111_
{
public struct S
{
public int i1, i2;
}
public class C
{
public S s;
}
class Program
{
static void Main(string[] args)
{
C myClass = new C();

// At this point, memory is allocated for the struct s inside the new
instance of C.

myClass.s.i1 = 999;
myClass.s.i2 = 888;
//at this point some memory must be assigned for
myClass.s.i1 & myClass.s.i2
//question: where this memory was taken from? From stack?
Or from heap?

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

}
}
}


-- Barry

--
http://barrkel.blogspot.com/
.



Relevant Pages