Summary
This article covered all the C# language constructs for decision making, looping, and jumping. For decision making, it showed if and switch statements and told when to use each. The three forms of the if statement are if, if-else, and if-else if-else. if and switch statements support branching to different logic, based on a decision.
The four loop typesthe while loop, the do loop, the for loop, and the foreach loopwere demonstrated. Loops permit repetition of logic sequences.
Branching statements and how each should be used were discussed. These branching statements included the goto statement, the break statement, the continue statement, and the return statement. Branching statements cause the flow of logic in a program to jump to another place in the code.
All the topics in this article were pulled together in Listing 1. Please experiment to see what else can be done with this program.