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
?
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
?
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.
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.