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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRavi Pratap M <ravi@mono-cvs.ximian.com>2001-10-21 14:07:17 +0400
committerRavi Pratap M <ravi@mono-cvs.ximian.com>2001-10-21 14:07:17 +0400
commit87bc7c82c05499180ec97fc7b0c002035118768a (patch)
tree4049b3db93668b9567b6d725ad95b01fef44485e /mcs/tests/test-27.cs
parentec8882d1d7799a7f4678a82cb35542996b152b10 (diff)
2001-10-21 Ravi Pratap <ravi@ximian.com>
* test-27.cs : Add to do various implicit and explicit reference conversions. * makefile : Update accordingly. svn path=/trunk/mcs/; revision=1187
Diffstat (limited to 'mcs/tests/test-27.cs')
-rw-r--r--mcs/tests/test-27.cs97
1 files changed, 97 insertions, 0 deletions
diff --git a/mcs/tests/test-27.cs b/mcs/tests/test-27.cs
new file mode 100644
index 00000000000..f1bd59b102a
--- /dev/null
+++ b/mcs/tests/test-27.cs
@@ -0,0 +1,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;
+
+ }
+}
+