sizeof(int) on x64?

iheartcsharp picture iheartcsharp · Mar 16, 2009 · Viewed 32.9k times · Source

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?

Answer

Andrew Hare picture Andrew Hare · Mar 16, 2009

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