Difference between long and int in C#?

后端 未结 6 641
日久生厌
日久生厌 2021-02-03 17:40

What is the actual difference between a long and an int in C#? I understand that in C/C++ long would be 64bit on some 64bit platforms(depending on OS o

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 18:21

    int is 32 bits in .NET. long is 64-bits. That is guaranteed. So, no, an int can't hold a long without losing data.

    There's a type whose size changes depending on the platform you're running on, which is IntPtr (and UIntPtr). This could be 32-bits or 64-bits.

提交回复
热议问题