gpt4 book ai didi

c# - 为什么 C# 中的 sizeof(bool) == sizeof(byte)?

转载 作者:太空狗 更新时间:2023-10-29 23:55:16 28 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
What is the binary representation of a boolean value in c#

根据MSDN documentationsizeof 关键字“用于获取非托管类型的字节大小”,原语被视为非托管类型。如果我检查 sizeof(bool),结果是 1。

在我看来,使用 boolean 值应该只需要一点内存。我错了吗?使用 Boolean 值实际上需要一个完整字节的内存吗?为什么?

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