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

Selection statements

Every application needs to be able to select from choices and branch along different code paths. The two selection statements in C# are if and switch. You can use if for all your code but switch can simplify your code in some common scenarios.

Using Visual Studio 2017

Start ...

Get C# 7 and .NET Core now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.