Summary

This chapter presented C# exceptions and exception handling. The first section introduced try/catch blocks. It showed how to use try/catch blocks to wrap up code where a possible exception may occur and to handle the exception when it occurs.

A section on the finally block explained how to make sure certain operations are always carried out, regardless of whether or not an exception occurs. The example showed how to release a system resource when an exception occurs.

I also talked about the predefined exception classes. I explained how they fit into a hierarchical organization.

This chapter also went in-depth to show various ways of handling exceptions, including how to handle multiple exceptions, handling and passing on exceptions to ...

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.