views:

35

answers:

3

For either List with n elements, which (if any) requires more storage on x64 machine:

List<int>

-or-

List<long>

I guess the question can be rephrased as:

On x64, does an int take any less space than a long?

A: 

See sizeof(int) on x64?

On any architecture, int is 32-bits and long is 64-bits

Mitch Wheat
+5  A: 

The int keyword is an alias for the System.Int32 type which is always 32 bits wide, regardless of platform. Likewise, the long keyword is an alias for the System.Int64 type which is always 64 bits wide, regardless of platform.

LukeH
A: 

List<long> will require 4 more bytes of memory per item. It doesn't matter if you're running on a 32 bit or a 64 bit OS, or if your .NET application targets 32 bit versus 64 bit.

Adal