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
What is the int.MaxValue on a 64-bit PC?
提问by g.revolution
System.Console.WriteLine(int.MaxValue);
This line gives me the answer of 2,147,483,647
as 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
回答by Daniel LeCheminant
Yes, the answer will be the same on a 64-bit machine.
是的,答案在 64 位机器上是一样的。
In .NET, an int
is 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
int
type represents signed 32-bit integers with values between–2,147,483,648
and2,147,483,647
.
该
int
类型表示值介于–2,147,483,648
和之间的有符号 32 位整数2,147,483,647
。
回答by Jon Skeet
int
is just an alias for Int32
- it's defined in the C# specification. Therefore int.MaxValue
is the same as Int32.MaxValue
which will always be 2147483647.
int
只是一个别名Int32
- 它在 C# 规范中定义。因此int.MaxValue
与Int32.MaxValue
2147483647 相同。