using System; public class ThrowException1App { public static void ThrowException() { throw new Exception(); } public static void Main() { try { Console.WriteLine("try..."); } catch(Exception e) { Console.WriteLine("catch..."); } finally { Console.WriteLine("finally"); } } }
As you can see, the existence of the finally keyword prevents you from having to put this cleanup code both in the catch block and after the try/catch blocks. Now, despite whether an exception is thrown, the code in the finally block will be executed.
by
updated