Chapter 4. Using Statements and Loops to Control Program Flow

In This Chapter

  • if Statements

  • switch Statements

  • C# Loops

  • goto Statements

  • break Statements

  • continue Statements

  • return Statements

This chapter provides the information needed to make logical decisions, iteratively execute a sequence of instructions, and modify the normal flow of control in programs. Although there is much more to C#, this chapter provides ample tools necessary to create useful, sophisticated programs.

For C++ and Java Programmers

Many of the statements in this chapter contain a Boolean expression for decision-making capability. A C++ program can interpret positive integers as true values; it does not work that way in C#. In C# the Boolean expression must return a true or ...

Get C# Unleashed 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.