The System.Exception Class


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.




C# 2.0(c) The Complete Reference
C# 2.0: The Complete Reference (Complete Reference Series)
ISBN: 0072262095
EAN: 2147483647
Year: 2006
Pages: 300

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net