Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Int32 vs. Int64 vs. Int in C# [duplicate]

Tags:

c#

.net

Possible Duplicate:
Assuming 32bit ints

So I read somewhere that int equals int32 in c#. Is it true also on 64-bit machines? Should I use int32 just to make sure no one at microsoft decides to change the size of int?

like image 801
Faruz Avatar asked Nov 05 '09 12:11

Faruz


People also ask

Is Int64 same as int?

1. Int16 is used to represents 16-bit signed integers. Int32 is used to represents 32-bit signed integers . Int64 is used to represents 64-bit signed integers.

Should I use int or Int64?

The types int8 , int16 , int32 , and int64 (and their unsigned counterparts) are best suited for data. An int64 is the typical choice when memory isn't an issue.

Is int and Int32 same?

Int32 is 32 bit, while int is 64 bit; int is 32 bit integer on 32 bit platform, while it is 64 bit on 64 bit platform; int is value type, while System.

Is Int32 and int the same C#?

Int32 is a type provided by . NET framework whereas int is an alias for Int32 in C# language.


1 Answers

int is an alias for Int32

long is an alias for Int64

Their sizes will not change, at all, just use whichever one you need to use.

The use of them in your code is in no way related to 32bit and 64bit machines

EDIT: In reference to the comments about Thread Safety. Here is a good question and answers that detail any issues you need to be aware of. Under C# is Int64 use on a 32 bit processor dangerous

like image 121
Robin Day Avatar answered Sep 28 '22 14:09

Robin Day