Sobes.tech
Junior — Senior

Output sequence when working with exceptions

livecode

Task condition

What will be the output order in the console when calling the method E.Bar()?

class E : IDisposable
{
    public void Dispose() => Console.WriteLine("Dispose!");

    public void Foo() => throw new Exception("Oh, no!");

    public static void Bar()
    {
        try
        {
            using (var e = new E())
            {
                e.Foo();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        finally
        {
            Console.WriteLine("Finally");
        }
    }
}