Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

43 lines
538 B
C#

//
// 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;
}
}