blob: 02b630e0225f14424756f8bb966eaee24fe63e90 (
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
|
//
// This is a compile test, submitted by Joe. We really need
// a more thorough set of tests for the user defined explicit
// conversions
//
using System;
class A {
public static explicit operator X (A foo)
{
X myX = new X();
return myX;
}
}
class X {
}
class Y : X {
}
class blah {
public static int Main ()
{
A testA = new A();
X testX = (X) testA;
try {
Y testY = (Y) testA;
} catch (InvalidCastException){
return 0;
}
//
// We should have thrown the exception above
//
return 1;
}
}
|