Re: Struct inside class
- From: Barry Kelly <barry.j.kelly@xxxxxxxxx>
- Date: Tue, 30 May 2006 11:38:45 +0100
"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/
.
- Follow-Ups:
- Re: Struct inside class
- From: Sneil
- Re: Struct inside class
- References:
- Struct inside class
- From: Sneil
- Struct inside class
- Prev by Date: Re: Is it not possible to inherit from DataRow?
- Next by Date: Re: how to open existing .aspx file in a new internet browser wind
- Previous by thread: Struct inside class
- Next by thread: Re: Struct inside class
- Index(es):
Relevant Pages
|