对象中的值类型也存储在堆中?

Value types in object stored in heap as well?(对象中的值类型也存储在堆中?)
本文介绍了对象中的值类型也存储在堆中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

它们存储在堆中,在为引用类型分配的内存中.此外,值类型通常存储在the堆栈".但是,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.

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)