Challenge 3: A using Declaration Disposing Despite an Exception — Possible Solution ==================================================================== Program.cs: class NoisyResource : IDisposable { public void Dispose() => Console.WriteLine("Dispose() called."); } static void RunDemo() { using var resource = new NoisyResource(); // using DECLARATION -- no braces Console.WriteLine("Inside the scope."); throw new InvalidOperationException("Something went wrong!"); // no code after this point in the method runs } try { RunDemo(); } catch (InvalidOperationException e) { Console.WriteLine("Caught: " + e.Message); } Output: Inside the scope. Dispose() called. Caught: Something went wrong! Explanation: `using var resource = ...;` is C# 8's using DECLARATION form -- there are no braces marking an explicit scope the way java1-7's own try-with-resources requires. Instead, resource is disposed automatically at the end of the ENCLOSING scope, which here is the end of RunDemo() itself. Even though an exception is thrown before the method reaches its natural end, Dispose() still runs during the method's exit (as the exception propagates out), BEFORE the exception reaches the outer catch block -- confirmed by the output order. WHY THIS WORKS AS AN ANSWER ------------------------------ This demonstrates the using declaration's more concise, brace-free syntax compared to java1-7's own try(...) block form, while confirming it provides the identical guarantee -- Dispose()/close() runs even when an exception is thrown before the scope ends normally.