asp.net C # int type has no change in the range of 32/64-bit environments

Source: Internet
Author: User

Recently in the study, I suddenly thought, I in 64-bit environment, int range of values have changed? To detect this result, I did the following test:
1, Environment: Win7 flagship 64-bit +VS2010 SP1 (version number: 10.0.40219.1sp1rel) +.net 4.0.30319 Sp1rel
2, Code:

The code is as follows Copy Code

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;

Namespace ConsoleApplication1
{
Class Program
{
static void Main (string[] args)
{
Console.WriteLine ("Maximum value of type int:" +int.) MaxValue);
Console.WriteLine ("Maximum value of Int64 type:" + int64.maxvalue);
Console.WriteLine ("Maximum of type long:" + long.) Maxvalue.tostring ());
Console.WriteLine ("Maximum value of ulong type:" + ulong.) Maxvalue.tostring ());
Console.readkey ();

}
}
}

As can be seen from the screenshot, the program ConsoleApplication1.exe has been running in 64-bit state (not 64-bit with *32), but the int is still 2.1 billion (decimal is not counted ^q^)
So, int in 64-bit environment, more than 2.1 billion or will overflow
Other than that. NET and the Int64 of C #, the values are the same.


The difference between C # int Int32 Int64
Int16 value types represent signed integers with values between 32768 and +32767.

Int32 value types represent signed integers with values between 2,147,483,648 and +2,147,483,647.

The Int64 value type represents an integer value between 9,223,372,036,854,775,808 and +9,223,372,036,854,775,807.

--------------------------------------------------------------------------------------------------------------- -------------

The short keyword represents an integer data type that stores values based on the size and range shown in the following table.

type Range size . NET Framework Types

Short

-32,768 to 32,767

Signed 16-bit integer

System.Int16

--------------------------------------------------------------------------------------------------------------- -------------

The int keyword represents an integral type that stores values based on the size and range shown in the following table.

type Range size . NET Framework Types

Int

-2,147,483,648 to 2,147,483,647

Signed 32-bit integer

System.Int32

--------------------------------------------------------------------------------------------------------------- -------------

The long keyword represents an integral type that stores values based on the size and range shown in the following table.

type Range size . NET Framework Types

Long

-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Signed 64-bit integer

System.Int64

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.