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 some good 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. You can use
if for all your code but
switch can simplify your code in some common scenarios.
Using Visual Studio 2017