C#中的int、long、float、double等类型都占多少个字节的内存

    Byte:  1 byte(s) scope:[0                               -                             255]
   SByte:  1 byte(s) scope:[-128                            -                             127]
   Int16:  2 byte(s) scope:[-32768                          -                           32767]
  UInt16:  2 byte(s) scope:[0                               -                           65535]
   Int32:  4 byte(s) scope:[-2147483648                     -                      2147483647]
  UInt32:  4 byte(s) scope:[0                               -                      4294967295]
   Int64:  8 byte(s) scope:[-9223372036854775808            -             9223372036854775807]
  UInt64:  8 byte(s) scope:[0                               -            18446744073709551615]
  Single:  4 byte(s) scope:[-3.4028235E+38                  -                   3.4028235E+38]
  Double:  8 byte(s) scope:[-1.7976931348623157E+308        -         1.7976931348623157E+308]
 Decimal: 16 byte(s) scope:[-79228162514264337593543950335  -   79228162514264337593543950335]
 Boolean:  1 byte(s)
    Char:  2 byte(s)
  IntPtr:  8 byte(s) 

以上结果需要注意,在32位系统中,IntPtr为4字节,在64位系统中,IntPtr为8字节。

拆解过程请看原帖 https://www.byteflying.com/archives/4396

 

posted @ 2020-09-02 10:53  大表哥的笔记  阅读(7127)  评论(0编辑  收藏  举报