[Microsoft.CSharp] Replaced with CoreFX implementation
[mono.git] / mcs / tests / test-727.cs
1 using System;
2
3 namespace IDisposableTest
4 {
5         class MainClass
6         {
7                 public static int Main ()
8                 {
9                         using (Foo f = new Foo ())
10                                 ;
11
12                         Console.WriteLine ("Between. Foo.TotalInstances = " + Foo.TotalInstances);
13
14                         using (IDisposable f = new Foo ())
15                                 ;
16
17                         Console.WriteLine ("After. Foo.TotalInstances = " + Foo.TotalInstances);
18
19                         if (Foo.TotalInstances != 2)
20                                 return 1;
21
22                         return 0;
23                 }
24         }
25
26
27         class Foo : IDisposable
28         {
29                 public static int TotalInstances = 0;
30
31                 private int my_a = 0;
32
33                 public Foo ()
34                 {
35                         my_a = TotalInstances++;
36                         Console.WriteLine ("Instance " + my_a + " ctor");
37                 }
38
39                 public void Dispose ()
40                 {
41                         Console.WriteLine ("Instance " + my_a + " Dispose()");
42                 }
43         }
44
45 }