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

test-27.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f1bd59b102aea3aa66fd8ea790db6a7d9da293a7 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;

public interface Hello {

	bool MyMethod (int i);
}

public interface Another : Hello {

	int AnotherMethod (int i);
}

public class Foo : Hello, Another {

	public bool MyMethod (int i)
	{
		if (i == 22)
			return true;
		else
			return false;
	}

	public int AnotherMethod (int i)
	{
		return i * 10;
	}
	
}

public interface ITest {

	bool TestMethod (int i, float j);
}

public class Blah : Foo {

	public delegate void MyDelegate (int i, int j);

	void Bar (int i, int j)
	{
		Console.WriteLine (i+j);
	}
	
	public static int Main ()
	{
		Blah k = new Blah ();

		Foo f = k;

		object o = k;

		if (f is Foo)
			Console.WriteLine ("I am a Foo!");

		Hello ihello = f;

		Another ianother = f;

		ihello = ianother; 

		bool b = f.MyMethod (22);

		MyDelegate del = new MyDelegate (k.Bar);

		del (2, 3);
		
		Delegate tmp = del;

		// Explicit reference conversions
		
		MyDelegate adel = (MyDelegate) tmp;

		adel (4, 7);

		Blah l = (Blah) o;

		l.Bar (20, 30);

		l = (Blah) f;

		l.Bar (2, 5);

		f = (Foo) ihello;

		// The following cause exceptions even though they are supposed to work
		// according to the spec

		// This one sounds ridiculous !
		// ITest t = (ITest) l;
		
		// ITest u = (ITest) ihello;

		return 0;

	}
}