sizeof(int) on x64?

The keyword int aliases System.Int32 which still requires 4 bytes, even on a 64-bit machine.


There are various 64-bit data models; Microsoft uses LP64 for .NET: both longs and pointers are 64-bits (although C-style pointers can only be used in C# in unsafe contexts or as a IntPtr value which cannot be used for pointer-arithmetic). 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 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.