ASP. NET learning notes (1) c # Yes

Source: Internet
Author: User

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

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.