I’ve created struct with static array of reference type and property which take object from that array by unique id stored in struct – but i don’t know it make any sense, i want to store struct on the stack.
struct TestStruct
{
static TestClass[] Instances = new TestClass[16];
int uid; //max value = 15
TestClass Instance
{
get { return Instances[uid]; }
}
}
Okay, so
Instancesis a static variable – so that will be on the heap. Likewise the array itself is a reference type, so that’s going to be on the heap.Only the
uidvariable is actually part of the value for a particular TestStruct, and that will be on the heap or on the stack depending on the context.It’s all an implementation detail though… what are you really trying to achieve?