An exception is an object (derived from
System.Exception) that contains
information about a problematic event. The framework supports
throwing exceptions to stop processing and catching events to
handle the problem and resume processing.
The stack is unwound until a handler is found, or else the exception is handled by the CLR, which terminates the program.
You create a
catch block; the
catch part is the exception
The syntax is:
throw new Sytem.Arg'umentNullException( )
You can write multiple exception handlers to handle different exceptions; the first handler that catches the thrown exception will prevent further handling. Beware of inheritance complications in the ordering of your handlers.
If you have code that must run whether or not an exception
is thrown (to close a file, for example), place that code in the
finally block. You must have a
try for the
finally, but a
catch is optional.
Cat class with
Age. Write a program that creates a
Cat objects in a
try block. Create multiple
catch statements to handle an
ArgumentOutOfRangeException, and an
unknown exception, and a
finally block to simulate deallocating
Cat objects. Write test
code to throw an exception that you will catch and
using System; ...