Life without try-catch-finally
Before we look at examples that implement the try-catch-finally trio introduced in the previous section, let's see what happens when an exception remains uncaught in your code. Listing 19.1 demonstrates this scenario.
Note
To see the same output as that shown in the sample output after Listing 19.1, you must compile the listing with the debug compiler switch on as follows:
csc /debug UncaughtException.cs<enter>
|
Listing 19.1. UncaughtException.cs
01: using System; 02: 03: class MyClass 04: { 05: public static void Main() 06: { 07: Console.WriteLine("Entering MyClass.Main"); 08: YourClass yourObject = new YourClass(); ... |
Get C# Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.