为什么Int64.MaxValue很长?

时间:2013-06-05 08:00:22

标签: c#

enter image description here

不应该是整数类型吗?

这样,一些使用int的函数无法接受这个作为参数,因为它返回一个long但是它们期望一个int

4 个答案:

答案 0 :(得分:18)

在.NET中,所有基元和一些标准化类型都有常见的内置类型别名。每个别名对应一个实际的.NET类型,别名和类型名称可以互换使用。

下面列出了C#中的一些别名。其他.NET语言可能对相同类型使用不同的别名(如VB.NET的情况)

    byte   -> System.Byte
    short  -> System.Int16
    int    -> System.Int32
    long   -> System.Int64
    string -> System.String
    ...

如您所见,System.Int64表示64位整数a.k.a.a long

答案 1 :(得分:7)

Int64long类型。

Int32int类型。

答案 2 :(得分:5)

.NET对某些类型使用类型别名。这意味着类型别名与其相对值类型完全等效。从下面的列表中可以看出,System.Int64的类型别名是“long”。以下是.NET中类型别名的完整列表。

//Alias      |  Relative Data Type
byte         |  System.Byte
sbyte        |  System.SByte
short        |  System.Int16
ushort       |  System.UInt16
int          |  System.Int32
uint         |  System.UInt32
long         |  System.Int64
ulong        |  System.UInt64
float        |  System.Single
double       |  System.Double
decimal      |  System.Decimal
string       |  System.String
bool         |  System.Boolean
object       |  System.Object

答案 3 :(得分:1)

  

长== Int64>>输出:True

     

Int == Int32>>输出:True

     

Int64 == Int32>>输出:False

如果它足够小,您只能将Long / Int64转换为Int / Int32,但您始终可以将Int转换为Long。 Int64 / Long支持的数字大于和小于标准Int。