C# 64 位 PC 上的 int.MaxValue 是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/647427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 11:39:24  来源:igfitidea点击:

What is the int.MaxValue on a 64-bit PC?

c#.netintint64int32

提问by g.revolution

System.Console.WriteLine(int.MaxValue);

This line gives me the answer of 2,147,483,647as I have a 32-bit PC.

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

Will the answer be same on a 64-bit PC?

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

采纳答案by Unknown

Yes.

是的。

int.MaxValue: 2,147,483,647

int.MaxValue:2,147,483,647

Source: https://www.dotnetperls.com/int-maxvalue

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

回答by Daniel LeCheminant

Yes, the answer will be the same on a 64-bit machine.

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

In .NET, an intis a signed 32-bit integer, regardless of the processor. Its .NET framework type is System.Int32.

在 .NET 中, anint一个有符号的 32 位整数,与处理器无关。它的 .NET 框架类型是System.Int32.

The C# Language specificationstates:

C#语言规范状态:

The inttype represents signed 32-bit integers with values between –2,147,483,648and 2,147,483,647.

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

回答by Jon Skeet

intis just an alias for Int32- it's defined in the C# specification. Therefore int.MaxValueis the same as Int32.MaxValuewhich will always be 2147483647.

int只是一个别名Int32- 它在 C# 规范中定义。因此int.MaxValueInt32.MaxValue2147483647 相同。