O'Reilly logo

C# Primer Plus by Klaus Michelsen

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

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(); ...

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