想知道占用的字节数,干嘛不直接问计算机呢

static void Main(string[] args) { //int 4 bytes Console.WriteLine("int {0} bytes", sizeof(int)); //char 2 bytes Console.WriteLine("char {0} bytes", sizeof(char)); //float 4 bytes Console.WriteLine("float {0} bytes", sizeof(float)); //double 8 bytes Console.WriteLine("double {0} bytes", sizeof(double)); //decimal 16 bytes Console.WriteLine("decimal {0} bytes", sizeof(decimal)); //byte 1 bytes Console.WriteLine("byte {0} bytes", sizeof(byte)); //short 2 bytes Console.WriteLine("short {0} bytes", sizeof(short)); //long 8 bytes Console.WriteLine("long {0} bytes", sizeof(long)); //bool 1 bytes Console.WriteLine("bool {0} bytes", sizeof(bool)); Console.ReadKey(); }
其中bool类型有些疑问。
在MSDN上查看时,其他类型的长度都是有写出的,就它没有列出。
http://msdn.microsoft.com/zh-cn/library/vstudio/c8f5xwh7.aspx
其中有什么特别之处吗?待解