我应该使用int还是Int32 [英] Should I use int or Int32
本文介绍了我应该使用int还是Int32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C#中, int
和 Int32
是同一回事,但是我读过很多次没有给出原因, int
比 Int32
更为可取。
In C#, int
and Int32
are the same thing, but I've read a number of times that int
is preferred over Int32
with no reason given. Is there a reason, and should I care?
推荐答案
ECMA-334 :2006 C#语言规范(p18):
ECMA-334:2006 C# Language Specification (p18):
每种预定义类型都是系统提供的类型的简写。例如,关键字
int
引用结构System.Int32
。就样式而言,与使用完整的系统类型名称相比,优先使用关键字。
Each of the predefined types is shorthand for a system-provided type. For example, the keyword
int
refers to the structSystem.Int32
. As a matter of style, use of the keyword is favoured over use of the complete system type name.
这篇关于我应该使用int还是Int32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文