static void Run3() { Console.WriteLine(); Console.WriteLine("Run3"); using var x = new Disposable1(); Console.WriteLine($"using {nameof(Disposable1)}"); using var y = new Disposable2(); Console.WriteLine($"using {nameof(Disposable2)}"); using var z = new Disposable3(); Console.WriteLine($"using {nameof(Disposable3)}"); }// here x, y and z will be disposed
static void Run2() { Console.WriteLine(); Console.WriteLine("Run2"); using (var x = new Disposable1()) { Console.WriteLine($"using {nameof(Disposable1)}"); using (var y = new Disposable2()) { Console.WriteLine($"using {nameof(Disposable2)}"); using (var z = new Disposable3()) { Console.WriteLine($"using {nameof(Disposable3)}"); } } } }