存储在堆中的对象中的值类型也是如此? [英] Value types in object stored in heap as well?

查看:114
本文介绍了存储在堆中的对象中的值类型也是如此?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以想象这个问题已经被问过数千遍了,但是我没有足够的运气来找到答案,而且这更多是出于好奇而不是需要.

I can imagine this question has been asked thousands of times, but I didn't have much luck in finding the answer, plus this is more out of curiosity than need.

深入研究C#的细节,我想知道既然对象存储在堆中,对象中的值类型也存储在堆中还是放置在堆栈中?

Digging into the nuts and bolts of C#, I was wondering since objects are stored in the heap, are the value types within the objects stored in the heap as well or are they placed in the stack?

推荐答案

它们存储在堆中,在为引用类型分配的内存中.另外,值类型通常存储在堆栈" .但是,CLI规范没有指定存储值类型的内存池所在的位置-这是无关紧要的实现细节.

They are stored in the heap, inside of the memory allocated for the reference type. In addition, value types are often stored in places other than "the stack". However, the CLI spec does not specify where the memory pool that stores value types resides - it's an implementation detail that should not matter.

这篇关于存储在堆中的对象中的值类型也是如此?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆