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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM