C # basic knowledge

Source: Internet
Author: User

Data Type:

Value Type and reference type

Value types include: simple type (integer type, real number type, character type, Boolean Type), structure type, enumeration type

Reference types include: Class, interface, array, delegate, and object and string. Object and string are two special types, object is the root class of all types (including all value types and reference types) in C #. string is a sealed type directly inherited from the object class (which cannot be inherited again ), its instance represents a unicode string.

Stack is a data structure that stores data items based on advanced and backward principles. heap is a region used for dynamic memory allocation, it can be allocated and released in any order and in any size. In C #, the value type is allocated to the stack, and the reference type is allocated to the stack.

Values of the value type and reference type can be assigned to the object type variable. C # converts the two types with "boxed" and "unpacking.

Packing: the so-called packing is the process of packaging the value type into the reference type

Binning: The binning operation is opposite to the packing operation. It is to convert an object into a value type: First, check the packaging value of the Value Type of the object instance referenced by the object, copy the value in the instance to the value type variable.

Note: When a boxing operation converts a value type to a reference type, you do not need to forcibly convert the type, and the unpacking operation converts the reference type to the value type, the emphasis type conversion must be displayed.

Constant:

Character constants and symbolic Constants

Integer constant: You can add l, l, u, u, UL to the end of the number. An integer constant can be expressed in decimal or hexadecimal notation (decimal by default, add 0x (or 0x) before the value)

Several important numbers need to be remembered: 128,256,327,

Floating-point constant: Generally, the number with a decimal point or the number expressed by scientific notation is considered as a floating point. Its data is of the double type by default, however, you can also add a suffix to indicate three different floating point formats, such as F, F, D, D, M, and M.

Character constant: a single character enclosed in single quotes, which occupies 16 digits and stores the Unicode code corresponding to this character in the form of unsigned integer numbers.

String constant: A String constant is a string of 0 or multiple characters enclosed in double quotation marks. C # two types of string constants are supported: Regular strings and verbatim strings.

Regular string: a string of characters enclosed in double quotes. It can contain escape characters.

A literal string: A literal string is formed by adding @ to the regular string. It means that each character in the string represents the intention and does not need to be escaped. If double quotation marks are required for a string, you can concatenate two double quotation marks to indicate a double quotation mark.

Boolean constant: there are only two values, true and false.

Symbol constant: Format: const type identifier = initial value

Variable: to create a variable is to create an instance of the variable type. The features of the variable are determined by its type. Format: type identifier [= initial value] [,...]


This article is from momok forward blog, please be sure to keep this source http://rainbow18.blog.51cto.com/8763958/1431574

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.