Chapter 3. Controlling the Flow, Converting Types, and Handling Exceptions
This chapter is about writing code that makes decisions, repeats blocks of statements, converts between types, and handles errors (known as exceptions). You will also learn about the best places to look for help.
This chapter covers the following topics:
- Selection statements
- Iteration statements
- Casting and converting between types
- Handling exceptions
- Checking for overflow
- Looking for help
Every application needs to be able to select from choices and branch along different code paths. The two selection statements in C# are
switch, also known as
switch-case. You can use
if for all your code but
switch can simplify your code in some common scenarios. ...