1. Variable Declaration: int n = 0;
The declaration must be assigned a value;
Multi-variable Declaration: int a = 1; B = 2
Type inference: var a = 1;
The compiler automatically deduce the variable type based on the value. This sentence is equivalent to int a = 1;
2. Scope
A. Local variable scope: the area in Braces Between the start and end of the method. Once the method ends, the variable disappears. If you call this local variable outside the method, this will cause an out-of-boundary.
B. Class scope: the area between the start and end of the class body. The variables defined in the class are called fields and can be used by all methods in the class.
Variables with the same name can only be declared once in the same scope;
3. Field and local variable scope conflict:
A. Category-level field
B. Call a class-level variable: Class Name. variable name, or use the this keyword.
4. Constants
Const int a = 12;
Once declared, the value cannot be changed.
5. if statement
A. the bool expression is moderately equal to ==,=, which is used to assign values;
B. In the if statement, even if there is only one line of code, {} is recommended {}
6. swich statement
A. The statement is more reproducible than the if statement;
B. Each branch statement must have a break;
C. The value after case must be a constant
7. foreach Loop
A. You do not need to know the number of elements in the set or array.
8. Jump statement
A. goto cannot jump to the cyclic code block, jump out of the class range, and exit the finally block after try catch;
B. break controls the statements after the execution cycle, which must be used in the loop;
C. continue must be used in the loop. Only the current loop is exited and the next loop is executed;
D. return the method for exiting the class and hand the control to the method caller;
By: dxh_0829