Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-115.cs
1 //
2 // This is a compile test, submitted by Joe.   We really need
3 // a more thorough set of tests for the user defined explicit
4 // conversions
5 //
6 using System;
7
8 class A {
9         public static explicit operator X (A foo)
10         {
11                 X myX = new X();
12
13                 return myX;
14         }
15 }
16
17 class X {
18 }
19
20 class Y : X {
21 }
22
23 class blah {
24         public static int Main ()
25         {
26                 A testA = new A();
27                 
28                 X testX = (X) testA;
29
30                 try {
31                         Y testY = (Y) testA;
32                 } catch (InvalidCastException){
33                         return 0;
34                 }
35
36                 //
37                 // We should have thrown the exception above
38                 //
39                 return 1;
40         }
41 }
42