Exception Handling: A Brief Overview

C#'s exception handling is object-oriented in that the exception generated by the execution engine in response to a special condition is an object that contains information about the corresponding abnormal condition. Any such exception object is either of class System.Exception or a subclass thereof. Typical predefined subclasses, found in the .NET Framework class library, are System.DivideByZeroException, System.InvalidOutOfRangeException, and System.NullReferenceException.

When an exceptional condition is encountered in a function, an exception object is created and thrown in that function. The function can catch (handle) the exception object itself or pass it on.

To implement code that monitors and handles ...

Get C# Primer Plus 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.