开发者

c# - is SHORT data type or it is still INT?

I am doing some classification and I am not sure:

INT is a primitive datatype with keyword "int"

But I can use Int16,Int32 or Int64 - I know C# has its own names for them. But are those data types as well or it is still INT? And mainly, can we 开发者_开发知识库say "short" is a datatype or INT16 is a datatype? Thanks :)


In C#, the following things are always true:

  • short == Int16
  • ushort == UInt16
  • int == Int32
  • uint == UInt32
  • long == Int64
  • ulong == UInt64

Both versions are data types. All of the above are integers of various lengths and signed-ness.

The main difference between the two versions (as far as I know) is what colour they are highlighted as in Visual Studio.


short is a data type representing 16-bit integers (1 order below int, which is 32-bit).

Int16 is in fact also a data type and is synonymous with short. That is,

Int16.Parse(someNumber);

also returns a short, same as:

short.Parse(someNumber)

Same goes with Int32 for int and Int64 for long.


In C#, int is just a shorter way of saying System.Int32.

In .NET, even the primitive data types are actually objects (derived from System.Object).

So an int in C# = an Integer in VB.Net = System.Int32.

there's a chart of all the .NET data types here: http://msdn.microsoft.com/en-us/library/47zceaw7%28VS.71%29.aspx

This is part of the .NET Common Type System that allows seamless interoperability between .NET languages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜