我创建了具有引用类型和属性的静态数组的结构,该结构通过存储在结构中的唯一 ID 从该数组中获取对象 - 但我不知道它有什么意义,我想将结构存储在堆栈上。
struct TestStruct
{
static TestClass[] Instances = new TestClass[16];
int uid; //max value = 15
TestClass Instance
{
get { return Instances[uid]; }
}
}
最佳答案
结构本身将存储在堆栈中。
TestClass 是您的引用类型。无论您做什么,这些都将存储在堆中。在这种情况下,Instances
是堆上的静态数组。
关于c# - 将引用类型作为属性的实时结构在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5079562/