In C#, exceptions are represented by classes. All exception classes must be derived from the built-in exception class Exception, which is part of the System namespace. Thus, all exceptions are subclasses of Exception.
From Exception are derived SystemException and ApplicationException. These support the two general categories of exceptions defined by C#: those generated by the C# runtime system (that is, the CLR) and those generated by application programs. Neither SystemException nor ApplicationException adds anything to Exception. They simply define the tops of two different exception hierarchies.
C# defines several built-in exceptions that are derived from SystemException. For example, when a division-by-zero is attempted, a DivideByZeroException is generated. As you will see later in this chapter, you can create your own exception classes by deriving them from ApplicationException.