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