C # the third day of basic learning (the path to growth of. net cainiao-No foundation to proficient ),

Source: Internet
Author: User

C # the third day of basic learning (the path to growth of. net cainiao-No foundation to proficient ),

1. compound assignment operator + =-= * =/= % =

2. Relational operators ><==! = Relational expressions connected by Relational operators are called relational expressions. Each expression can be used to calculate a fixed value.

3. We use the bool type in c # To describe the right or wrong bool type. The bool type has only two values: true and false.

4. logical operator logic and & (shift + 7) logic or | (shift + Don) logic is not! (Must be an English exclamation point) for logic and logic or operators, we need to place bool values or relational expressions on both sides of the operators. The priority of logic and is higher than that of logic or, which means that in a logical expression, if there are both logic and logic or, we should first calculate the logic and. 5. Learning the Sequence Structure of the syntax structure in c #: The program enters from the Main function, and the execution of one line from top to bottom won't fall into every line of code. Branch Structure ---> if structure ---> if-else structure selection structure (for multi-condition judgment, more than two conditions are considered as multi-condition) --> if else-if Structure --> switch-case structure --> while LOOP --> do-while loop --> for loop --> foreach Loop

6. if structure Syntax: if (bool type value, relational expression, or logical expression) {code to be executed;} Execution Process: The program runs to if, first, judge the value in the parentheses following the if statement. if it is true, the code is executed in the braces included in the if statement. If it is false, the braces are skipped and nothing is executed. Execution features: first judge and then execute. A Code may not be executed.

7. if-else structure Syntax: if (bool type value, relational expression, or logical expression) {code to be executed;} else {code to be executed;} execution process: the program first checks whether the condition in the parentheses of if is true. if it is true, the code in the braces of if is executed. After the execution is complete, the if-else structure is displayed. If the if condition returns false, the braces included in if are skipped and the code in else is executed. Execution features: First Judge and execute, but at least one piece of code is executed (either if or else). Note: else always matches the if nearest to it. 8. if else-if Syntax: if (Judgment condition) {code to be executed;} else if (Judgment condition) {code to be executed;} else if (Judgment condition) {code to be executed ;}...... else {code to be executed;} Execution Process: The program first checks whether the judgment condition of the first if is true. if so, the code in the braces included in the if statement is executed, after the execution is complete, the entire if else-if structure exists. If the first if clause is not true, the next clause is used to judge the conditions of each if clause. if the first if clause is true, the next clause is used to judge the conditions of each if clause, check whether else exists in the current if else-if structure. if else exists, run the code in else. if no else exists, the if else-if structure does not do anything. 9. Exception capture may cause exceptions. Let's take appropriate measures so that even if an exception occurs, it will not cause my application to crash. Try {} catch {} usage: Write codes that may encounter exceptions in try, and write the code to be executed after exceptions in catch. TIPS: if an exception occurs, you can throw it. Execution Process: If there is no exception in the try code, the catch code will not be executed. If an exception occurs in the code in try, it will immediately jump to catch for execution. Even if there are one hundred lines of code after the exception occurs in try, it will not be executed. 10. variables declared in the function scope are called local variables. Local variables have scopes. Scope refers to the range in which we can access or use this variable. The scope of a local variable starts from the braces that declare it, and ends with the ending braces corresponding to the braces. If we can access or operate a variable within this range, we cannot perform any operations on the variable.

 

11. For the judgment of Multi-condition statements, we recommend that you use the if else-if and switch-case structures. if the judgment of multiple conditions is interval, we recommend that you use if else-if. We recommend that you use the switch-case structure if the multi-condition is set. Switch-case structure Syntax: switch (value of a variable or expression) {case value 1: code to be executed; break; case value 2: code to be executed; break; case value 3: code to be executed; break; default: code to be executed; break; // jump out of the current switch-case structure. } Execution Process: The program runs to the switch and calculates the result in parentheses of the switch. Match the calculated result with the value of each case. If the match is successful, the Code included in the case is executed. After the execution is complete, the break occurs and the switch-case structure exists. If it does not match the value of each case, check whether there is a default in the current switch-case structure. If there is a default, execute the code in the default. If not, the switch-case structure does nothing.

Video tutorial: http://yunpan.cn/ccZZ6UkXdP64s access password 2fb6

I am going to attend the training recently! Therefore, updates may not be released in time! More Videos can be added to groups for communication!

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.