gpt4 book ai didi

c# - 使用 stackalloc 分配的内存的初始化

转载 作者:太空狗 更新时间:2023-10-29 17:37:08 26 4
gpt4 key购买 nike

如果我在 C# 中使用 stackalloc 分配内存,内存是否已初始化(使用 0)?
文档没有提到这一点,只说明保留了正确的金额。

在我的测试中,此类内存默认为 0,但这并不意味着它是有保证的。

最佳答案

来自规范:

18.8 Stack allocation

The content of the newly allocated memory is undefined.

关于c# - 使用 stackalloc 分配的内存的初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8679052/

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