Chapter 10. Handling Exceptions and Errors

In This Chapter

  • try/catch Blocks

  • finally Blocks

  • Predefined Exception Classes

  • Handling Exceptions

  • Designing Your Own Exceptions

  • checked and unchecked Statements

This chapter discusses C# support for error handling and exceptions. Error handling is the technique of successfully trapping expected and unexpected runtime errors. The goal is to be able to anticipate errors before they occur. This makes a program more robust and promotes graceful degradation.

In C#, error handling is built around exceptions. Exceptions are special occurrences in a program that indicate an error condition. When an error occurs, an exception is thrown. The program should be constructed, using error-handling techniques, to catch

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.