O'Reilly logo

C# 4.0 Unleashed by Bart De Smet

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

try Statements

Block-based exception handling is one of the core features of structured exception handling. The try statement in languages like C# reflects this. Associated with the try block are catch handlers and/or a single finally block. All forms shown here are valid based on those rules. First, a single handler:

image

Second, use of multiple handlers

image

All these can have a finally block at the bottom, but that block can also be used in the absence of any catch blocks:

The use of a try statement with only a finally block is exactly what the using ...

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