C # language-03. Logical Control Statements

Source: Internet
Author: User

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

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.