gpt4 book ai didi

c# - 对象中的值类型也存储在堆中吗?

转载 作者:太空狗 更新时间:2023-10-29 20:49:39 25 4
gpt4 key购买 nike

我可以想象这个问题已被问过数千次,但我并没有找到答案,而且这更多是出于好奇而不是需要。

深入了解 C# 的具体细节,我想知道既然对象存储在堆中,那么对象中的值类型是否也存储在堆中,还是放在堆栈中?

最佳答案

Andrew Hare 是对的。有关完整详细信息,请参阅 Eric Lippert's blog entry :

I'm disturbed by the myth that "value types go on the stack" ... It is usually stated incorrectly: the statement should be "value types can be stored on the stack", instead of the more common "value types are always stored on the stack".

关于c# - 对象中的值类型也存储在堆中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4727910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com