F
faustino Dina
Hi,
I have a question about how C# handles struct. From the help, struct
variables are stored in the stack while class objects are stored in the
heap. Then what happens when I add a struct value to a colection?
struct MyStruct
{
public int X;
}
MyStruct s;
ArrayList list = new ArrayList();
list.Add(s);
In C/C++ store stack addresses on a global collection can lead to hard to
trace problems. But how C# works? In this case what is stored on the list
collection: struct, a reference to the stack or s is cloned into the heap
and that reference is added to the collection?
Thanks in advance
I have a question about how C# handles struct. From the help, struct
variables are stored in the stack while class objects are stored in the
heap. Then what happens when I add a struct value to a colection?
struct MyStruct
{
public int X;
}
MyStruct s;
ArrayList list = new ArrayList();
list.Add(s);
In C/C++ store stack addresses on a global collection can lead to hard to
trace problems. But how C# works? In this case what is stored on the list
collection: struct, a reference to the stack or s is cloned into the heap
and that reference is added to the collection?
Thanks in advance