如何值类型的数组存储在.NET对象堆?数组、对象、类型、NET

2023-09-04 22:53:55 作者:世界再好也不及你

在.NET中,值类型的对象,如int存储在内存中。

In .NET, Value type object such as int is stored in memory.

引用类型的对象,需要的内存的引用和对象单独分配,而对象存储在.NET对象堆。

Reference type object requires separate allocations of memory for the reference and object, and the object is stored in .NET object heap.

和数组是在堆上创建的,所以值类型的数组,如int []存储在堆怎么样?这是否意味着值类型的对象可以存储在堆没有拳击?

And Array is created in the heap, so how an array of value types such as int[] stored in the heap? Does it mean value type object can be stored in the heap without boxing?

推荐答案

是的,你是对的。我建议你​​这样说的:

Yes, you are right. I suggest you read this:

http://blogs.msdn.com/b/ericlippert/archive/2010/09/30/the-truth-about-value-types.aspx

这是非常非常好,它说明了你永远想知道的几乎一切。

It's very very good, and it explains nearly everything you'll ever want to know.