tutorial

Page 199

using System; class HelloNested { static void Main(string[] args) { try { try { throw new Exception("It's just too warm in here !"); } catch(Exception exInner) { // Display the exception message Console.WriteLine("Inner catch caught an exception: {0}", exInner.Message); } finally { // The inner finally block that executes always Console.WriteLine("Inner finally"); } // Continue execution in the Outer try block Console.WriteLine("Continue executing in Outer ..."); } catch(Exception exOuter) { // Display the exception message Console.WriteLine("Outer catch caught an exception: {0}", exOuter.Message); } finally { // The outer finally block that executes always Console.WriteLine("Outer finally"); } } }

Code listing in VB.NET Imports System

Module HelloNested Sub Main()

' This is the beginning of the Outer Try block Try ' This is the beginning of the Inner Try block Try Throw New Exception("It's just too warm in here !")


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.