0 votes
by (2.5k points)

In C#, there appears to be int, Int32 and Int64. Are these all the same things? Should I use the Int32 if I'm on a 32 bit machine? 

int myInteger;
Int32 myOtherInteger;
Int64 anotherInteger;

1 Answer

0 votes
by (2.5k points)

I'll answer one part of your question before going into the rest.

"Should I use the Int32 if I'm on a 32 bit machine?"

The answer is no. The 32 and 64 do refer to bits, but not of the host/target machine. Use of these have nothing to do with the architecture of your machine.

The best way to describe it would be :

Int16 - Has 16 bits to store a value, therefore can store values -32,768 to +32,767
Int32 - Has 32 bits to store a value, therefore can store values -2,147,483,648 to +2,147,483,647
Int64 - Has 62 bits to store a value, therefore can store values -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807

However, C# provides us with aliases like so :

Int16 has the alias of "short"
Int32 has the alias of "int"
Int64 has the alias of "long"

So the differences between Int32 and Int64 are about storage size (And therefore the max values), and the difference between int and Int32 is that int is an alias for Int32 (So they are the same thing!).

Welcome to .NET Q&A, where you can ask questions and receive answers from other members of the community.
...