Lecture overview -- Keyboard shortcut: 'u'  Previous page: Exceptions in a C# program -- Keyboard shortcut: 'p'  Next page: Handling exceptions in C# -- 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 17 : 30
Object-oriented Programming in C#
Exception Handling
The try-catch statement C#

The try-catch statement allows us handle certain exceptions instead of stopping the program

catch (exception-type-1 name)
catch (exception-type-2 name)

The syntax of the try-catch statement C#

  • Program fragments that may lead to potential exceptions

    • In try-block

  • Program fragments that may handle the exceptions

    • In catch-block-1, catch-block-2, ...