C # and the database in the field type Int16 (short), Int32 (int), Int64 (long), the range of values, differences. String length

Source: Internet
Author: User

At first see Int16, Int32, Int64 These three kinds of types feel a bit strange, why want the whole number end of, very strange.

Yesterday thought to each other, Ms so do is to let everyone at a glance know how much space this data type.

Int8, equal to Byte,

Int16, equal to short, accounts for 2 bytes. -32768 32767

Int32, equal to int, accounting for 4 bytes. -2147483648 2147483647

Int64, which is equal to a long, takes up 8 bytes. -9223372036854775808 9223372036854775807

In this way, it looks more intuitive than Short,int,long!

In addition, there is a byte, which is equal to Byte, 0-255.

So int8 16 32 64 is the alias of the short int long

1. We use String. Length reads string lengths, which are of type int, so theoretically int32.maxvalue is a string. The maximum value the Length can reach.
2. NET a single object in memory must not exceed 2GB, using Unicode encoded string type each character occupies 2 bytes, so the maximum length is 1,073,741,823. And this length is not sufficient in a 32-bit system.
The information has the talent in a realistic scientific rigorous attitude to test, ran to 1,000,000,000 after the tragedy, so the conclusion is able to more than 1,000,000,000, but then memory overflow. In fact, I also tested, but did not see up to a few on the memory overflow ...

C # and the database in the field type Int16 (short), Int32 (int), Int64 (long), the range of values, differences. String length

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.