Summary

The bulk of this chapter focused on the if-else and switch branching statements and their related language elements—the comparison and logical operators. Together they allow you to write decision-making programs that can react in different ways to different data.

The most important points discussed in this chapter are reviewed in this section.

A branching statement is a language construct that uses a given condition (Boolean expression) to decide between two or more alternative directions (branches) to follow in a program.

A program without any branching or iteration statements is executed sequentially, in the order (from top to bottom) that the statements are written in the source code.

The if statement is the fundamental branching statement ...

Get C# Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.