0429 data types

Source: Internet
Author: User

First, the data type

Basic data types are: Integer, float, Boolean, character

Integer (Stored integer Class): int short Long byte

Floating point type (deposit decimal): Double float Decimal

Boolean (True or FALSE): BOOL

Character type (one character only): Char

Ii. Variables and constants

Definition of variable: Data type variable name [= value]//where the value within [] can not be written

Example: int a=1;

Naming rules for variables:

① variable names can only be composed of letters, numbers, underscores, @, kanji

② The first letter can only be letters, underscores, @, kanji; Cannot use numbers or constants

③ cannot be duplicate with keyword

Definition of constants: const data type variable name [= value]

Example: const int a=1;

Constants must be assigned when defined, and constants cannot be modified after they are defined.

Constants can be placed on the left side of the equals sign only when defined.

Third, data conversion

When a computer uses data operations, it uses the same type of data to perform operations, and data conversions are required if different data types are used

Conversion types are divided into: auto-transform (implicit conversion); cast (explicit conversion)

Automatic conversion: Automatically converts as long as there is no data loss

Byte->short->int->long->float->double//The type conversion of this order can be automatically converted

Cast: In cases where data loss may occur, you must cast the

Conversion method: ① The left side of the converted data with parentheses (the data type to be converted)

② using convert.toxxx (data to be converted)

Note: If it is a character conversion, you must use Convert.toxxx

Iv. C # Escape characters

Tab:/T backslash://Single quote:/' double quotation mark:/' Enter:/R newline:/n

Warning:/A backspace:/b Change page:/F null:/0

0429 Data type

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.