【问题标题】:What is the int.MaxValue on a 64-bit PC?64 位 PC 上的 int.MaxValue 是什么?
【发布时间】:2009-03-15 07:14:14
【问题描述】:
System.Console.WriteLine(int.MaxValue);

这行给出了2,147,483,647 的答案,因为我有一台 32 位 PC。

在 64 位 PC 上答案是否相同?

【问题讨论】:

    标签: c# .net int int64 int32


    【解决方案1】:

    是的。

    int.MaxValue: 2,147,483,647

    来源:https://www.dotnetperls.com/int-maxvalue

    【讨论】:

      【解决方案2】:

      是的,答案在 64 位机器上是一样的。

      在 .NET 中,inta signed 32-bit integer,与处理器无关。它的 .NET 框架类型是System.Int32

      C# Language specification 声明:

      int 类型表示带符号的 32 位 值介于之间的整数 –2,147,483,6482,147,483,647

      【讨论】:

        【解决方案3】:

        int 只是Int32 的别名——它在 C# 规范中定义。因此int.MaxValueInt32.MaxValue 相同,Int32.MaxValue 始终为 2147483647。

        【讨论】:

        猜你喜欢
        • 2011-12-03
        • 2012-07-19
        • 2012-09-10
        • 2011-09-16
        • 1970-01-01
        • 1970-01-01
        • 2010-11-09
        • 2014-07-31
        • 2012-03-12
        相关资源
        最近更新 更多