sizeof(int) on x64?

When I do sizeof(int) in my C#.NET project I get a return value of 4. I set the project type to x64, so why does it say 4 instead of 8? Is this because I'm running managed code?


There are various 64-bit data models; Microsoft uses LP64 for .NET: both longs and pointers are 64-bits (although traditional C-style pointers don't exist .NET). Contrast this with ILP64 where ints are also 64-bits.

Thus, on all platforms, int is 32-bits and long is 64-bits; you can see this in the names of the underlying types System.Int32 and System.Int64.


关键字int别名System.Int32 ,即使在64位计算机上也需要4个字节。


int means Int32 in .NET languages. This was done for compatibility between 32- and 64-bit architectures.

Here's the table of all the types in C# and what they map to .NET wise.

链接地址: http://www.djcxy.com/p/476.html

上一篇: const和readonly有什么区别?

下一篇: sizeof(int)在x64上?