eol
[mcs.git] / tests / test-27.cs
blobf1bd59b102aea3aa66fd8ea790db6a7d9da293a7
1 using System;
3 public interface Hello {
5 bool MyMethod (int i);
8 public interface Another : Hello {
10 int AnotherMethod (int i);
13 public class Foo : Hello, Another {
15 public bool MyMethod (int i)
17 if (i == 22)
18 return true;
19 else
20 return false;
23 public int AnotherMethod (int i)
25 return i * 10;
30 public interface ITest {
32 bool TestMethod (int i, float j);
35 public class Blah : Foo {
37 public delegate void MyDelegate (int i, int j);
39 void Bar (int i, int j)
41 Console.WriteLine (i+j);
44 public static int Main ()
46 Blah k = new Blah ();
48 Foo f = k;
50 object o = k;
52 if (f is Foo)
53 Console.WriteLine ("I am a Foo!");
55 Hello ihello = f;
57 Another ianother = f;
59 ihello = ianother;
61 bool b = f.MyMethod (22);
63 MyDelegate del = new MyDelegate (k.Bar);
65 del (2, 3);
67 Delegate tmp = del;
69 // Explicit reference conversions
71 MyDelegate adel = (MyDelegate) tmp;
73 adel (4, 7);
75 Blah l = (Blah) o;
77 l.Bar (20, 30);
79 l = (Blah) f;
81 l.Bar (2, 5);
83 f = (Foo) ihello;
85 // The following cause exceptions even though they are supposed to work
86 // according to the spec
88 // This one sounds ridiculous !
89 // ITest t = (ITest) l;
91 // ITest u = (ITest) ihello;
93 return 0;