INT,Int16的,的Int32和Int64的之间的区别是什么?
与 INT
, System.Int16
, System.Int32的和
System.Int64
比它们的大小等?
What is the difference between int
, System.Int16
, System.Int32
and System.Int64
other than their sizes?
每个整数类型都有不同幅度的存储容量
Each type of integer has a different range of storage capacity
Type Capacity
Int16 -- (-32,768 to +32,767)
Int32 -- (-2,147,483,648 to +2,147,483,647)
Int64 -- (-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807)
INT
和的Int32
确实是同义的; INT
会多一点眼熟,的Int32
使得32位数更加明确那些读你的code。我会倾向于使用int,我只是需要'整',的Int32
,其中大小是很重要的(加密code,结构),所以将来的维护者就知道它的安全放大的 INT
如果合适的话,但应注意以同样的方式改变的Int32
变量。
由此产生的code将是相同的:不同的是纯粹的可读性或code外观之一
int
and Int32
are indeed synonymous; int
will be a little more familiar looking, Int32
makes the 32-bitness more explicit to those reading your code. I would be inclined to use int where I just need 'an integer', Int32
where the size is important (cryptographic code, structures) so future maintainers will know it's safe to enlarge an int
if appropriate, but should take care changing Int32
variables in the same way.
The resulting code will be identical: the difference is purely one of readability or code appearance.