O'Reilly logo

Graphics Programming with GDI+ by Mahesh Chand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A.2. Understanding the try...catch Block

If you come from a Visual Basic background, we recommend that you just forget about unstructured exception handling and learn this new approach using the try...catch statement. After you finish reading this appendix, you’ll find the structured approach much better!

A.2.1. The try...catch Statement

Using the try...catch statement is very straightforward. First we decide which code we want the error handler to monitor by placing that code inside the try block. When an exception occurs in the encapsulated code, a control goes to the catch block that handles the exception. A simple template for a try...catch block is shown in Listing A.3.

Listing A.3. A simple try...catch block
 try { // Place the code that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required