3 namespace IDisposableTest
7 public static int Main ()
9 using (Foo f
= new Foo ())
12 Console
.WriteLine ("Between. Foo.TotalInstances = " + Foo
.TotalInstances
);
14 using (IDisposable f
= new Foo ())
17 Console
.WriteLine ("After. Foo.TotalInstances = " + Foo
.TotalInstances
);
19 if (Foo
.TotalInstances
!= 2)
27 class Foo
: IDisposable
29 public static int TotalInstances
= 0;
35 my_a
= TotalInstances
++;
36 Console
.WriteLine ("Instance " + my_a
+ " ctor");
39 public void Dispose ()
41 Console
.WriteLine ("Instance " + my_a
+ " Dispose()");