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

gtest-039.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7c94c8acfa3a5c0846da93cc186e71e6a1a4df92 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Important test for the runtime: check whether we're correctly
// creating the vtable for nested types.
//

using System;

interface IMonkey<T>
{
	T Jump ();
}

class Zoo<T>
{
	T t;

	public Zoo (T t)
	{
		this.t = t;
	}

	public T Name {
		get { return t; }
	}

	public IMonkey<U> GetTheMonkey<U> (U u)
	{
		return new Monkey<T,U> (this, u);
	}

	public class Monkey<V,W> : IMonkey<W>
	{
		public readonly Zoo<V> Zoo;
		public readonly W Data;

		public Monkey (Zoo<V> zoo, W data)
		{
			this.Zoo = zoo;
			this.Data = data;
		}

		public W Jump ()
		{
			Console.WriteLine ("Monkey {0} from {1} jumping!", Data, Zoo.Name);
			return Data;
		}
	}
}

class X
{
	public static void Main ()
	{
		Zoo<string> zoo = new Zoo<string> ("Boston");
		IMonkey<float> monkey = zoo.GetTheMonkey<float> (3.14F);
		monkey.Jump ();
	}
}