Multiple finally blocks : finally « Statement « Visual C++ .NET






Multiple finally blocks

 

#include "stdafx.h"
using namespace System;

int main()
{
   try
   {
       try
       {
           throw gcnew Exception("XYZ");

       }
       catch( Exception^ exception)
       {
           Console::WriteLine("Inner catch");
       }
       finally
       {
           Console::WriteLine("Inner finally");
       }
   }
   catch(Exception^ exception)
   {
        Console::WriteLine("Outer catch");
   }
   finally
   {
        Console::WriteLine("Outer finally");
   }
}

   
  








Related examples in the same category

1.Exception Finally
2.finally block of exceptin catching