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

2019-04-18 01:40发布

System.Console.WriteLine(int.MaxValue);

This line gives me the answer of 2147483647 as I have a 32-bit PC.

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

3条回答
甜甜的少女心
2楼-- · 2019-04-18 01:56

Yes.

int.MaxValue: 2,147,483,647

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

查看更多
Viruses.
3楼-- · 2019-04-18 02:00

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.

查看更多
女痞
4楼-- · 2019-04-18 02:11

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

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

The C# Language specification states:

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

查看更多
登录 后发表回答