An exception occurs when a program encounters any unexpected problem, such as running out of memory or attempting to read from a file that no longer exists. An exception generally results in abruptly terminating the program after displaying an error message. Ideally, your program should be capable of handling these exceptional situations and, if possible, gracefully recover from them. This is called exception handling . Proper use of exception handling can make your programs robust, as well as easy to develop and maintain. The Common Language Runtime (CLR) views an exception as any object that encapsulates any information about the problems that occurred during program execution. The FCL provides two categories of exceptions:
Both of these exception classes derive from the base Exception class. Table 5.1 lists the important properties of all three of these classes. Table 5.1. Important Properties of the Exception Class
|