Understanding conditional/selection statements

C# offers multiple conditional/selection statements to help us make decisions throughout our programming. We can use all of the operators we learned about in the previous sections alongside these statements. These statements help the program take on a specific flow based on whether the expression is evaluated as true or false. These statements are the most widely used ones in C#.

The following table lists the available conditional/selection statements:

Expression Description
If..else If statements evaluate the expression that's provided. If it is true, then the statements are executed. If it is false, then else statements are executed.
Switch..case..default Switch statements evaluate a specific expression and execute the switch section if the pattern matches the match expression.
break break allows us to terminate a control flow and move on to the next statement.
goto goto is used to transfer control to a specific label when the expression evaluates to true.

 

In the following subsections, we will cover each of these statements in detail.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.170.223