Introduction to C # data types in asp.net (1/5)

Source: Internet
Author: User

4.1 Value types

The various value types always contain a value of the corresponding type. C # forces you to initialize variables to use them for calculation-variables that are not initialized will not cause problems because when you attempt to use them, the compiler will tell you. Whenever a value is assigned to a value type, the value is actually copied. In contrast, for reference types, only the reference is copied, and the actual value remains in the same memory location, but now two objects are pointing to it (referencing it). The value types of C # can be categorized as follows:
• Simple Type (plain types)
• Structure type (struct types)
• Enumeration type (enumeration types)

4.1.1 Simple Type

Simple types that appear in C # share some attributes. First, they are all. NET system type alias. Second, a constant expression consisting of simple types is detected only at compile time and not at runtime. Finally, simple types can be initialized literally. The following is a C # Simple type collation:
• Integral type
• Boolean type
• Character type (a special case of an integral type)
• Floating-point type
• Decimal Type

4.1.1.1 Integral type
There are 9 integral types in C #. SByte, Byte, short, ushort, int, uint, long, ulong, and char (discussed in a separate section). They have the following characteristics:

The sbyte type is a signed 8-bit integer with a value range between 128~127.
The bytet type is an unsigned 16-bit integer with a value range between 0~255.
The short type is a signed 16-bit integer with a value range between -32,768~32,767.
The ushort type is an unsigned 16-bit integer with a value range between 0~65,535.
The int type is a signed 32-bit integer with a value range between -2,147,483,648~ 2,147,483,647.
The uint type is an unsigned 32-bit integer with a value range between 0 ~ 4,294,967,295.
The long type is a 64-bit signed integer with a value range between 9,223,372,036,854,775,808~ 9,223,372,036,854,775,807.
The ulong type is a 64-bit unsigned integer with a value range between 0 ~ 18,446,744,073,709,551,615.

Both VB and C programmers may be surprised by the new range represented by the int and long data types. In C #, the int no longer depends on the size of the word (word) of a machine, and long is set to 64 bits, compared to other programming languages.

4.1.1.2 Boolean type

The Boolean data type has True and false two Boolean values. You can assign a value of TRUE or False to a Boolean variable, or you can assign an expression that evaluates to one of two:
BOOL Btest = (> 90);
In C #, the true value is no longer any value other than C and C + +. Do not convert other integral types to Boolean for added convenience.

Home 1 2 3 4 5 last
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.