Lecture overview -- Keyboard shortcut: 'u'  Previous page: Propagation of exceptions in C# -- Keyboard shortcut: 'p'  Next page: Try-catch with a finally clause -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 23 : 30
Object-oriented Programming in C#
Exception Handling
Raising and throwing exceptions in C#

We are using an athletic metaphor for establishing an error condition


 throw exception-object

The syntax of exception throwing in C#

...
throw new MyException("Description of problem");
...

A throw statement in C#.

class MyException: ApplicationException{
  public MyException(String problem): 
    base(problem){
  }
}   

Definition of the exception class.