A. Logical control statement: I. Conditional statement:the condition is judged first, then the different branches are executed according to the result of judgment . 1. If andif-Else: Determine the value of a Boolean expression to determine the execution of that block of code A. Syntax:if(Boolean expression) {B. Boolean expression istruewhen executing this code block C.}Else{D. Boolean expression isfalsewhen executing this code block E.} 2.Switch: Judge the "value of the control expression" to conditionally execute code a. Syntax:Switch() {B. CaseTest value1: C. Break; D .... E. default: F. Break; G.} II. Loop statement: can conditionally implement the loop operation of a statement segment 1. Do... whilestatement: Executes the code first and then determines whether the loop condition A. Syntax is met: Do{B. Loop code c.} while(Boolean expression)2. whilestatement: First determine whether the loop condition is met, then execute code A. Syntax: while(Boolean expression) {B. Loop code c.} 3. forstatement: You can perform a specified number of times and maintain its own counter a. Syntax: for(cyclic variable initialization; loop condition; cyclic operation) b. Loop code C.} 4.foreachstatement: Enumerates all the elements in a collection and executes the nested statement a. Syntax for each element in the collection:foreach(type identifierinchexpression) b. Loop code C.} 5. Jump statement: You can execute the branch of the program, transfer program control, change the process, the unconditional jump A. Break statement: Terminate and jump out of the loop B. Continue statement: Terminates the current loop and starts again A new loop C. Gogo statement: Jumps to the specified location and is not recommended because it may break the program's structural d. Return statement: Jump out of the loop and the functions it contains E. Throw statement: Throws an exception1. Double cycle:each time the outer loop is executed, the inner loop is executed completely from beginning to end.
C # language-03. Logical Control Statements