Why is a boolean 4 bytes in .NET?

前端 未结 6 2273
我在风中等你
我在风中等你 2020-11-29 07:54

Why does a System.Boolean take 4 bytes? It just stores one state, either true or false, which could be stored in less space than 4 bytes.

6条回答
  •  感动是毒
    2020-11-29 08:44

    Where'd you get that? System.Boolean takes only 1 byte.

    Just try:

    Console.WriteLine( sizeof( System.Boolean ).ToString() );
    

提交回复
热议问题