Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-727.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 913a5ea79708b1c624221217d2427ee65ab49b99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;

namespace IDisposableTest
{
	class MainClass
	{
		public static int Main ()
		{
			using (Foo f = new Foo ())
				;

			Console.WriteLine ("Between. Foo.TotalInstances = " + Foo.TotalInstances);

			using (IDisposable f = new Foo ())
				;

			Console.WriteLine ("After. Foo.TotalInstances = " + Foo.TotalInstances);

			if (Foo.TotalInstances != 2)
				return 1;

			return 0;
		}
	}


	class Foo : IDisposable
	{
		public static int TotalInstances = 0;

		private int my_a = 0;

		public Foo ()
		{
			my_a = TotalInstances++;
			Console.WriteLine ("Instance " + my_a + " ctor");
		}

		public void Dispose ()
		{
			Console.WriteLine ("Instance " + my_a + " Dispose()");
		}
	}

}