namespace Mine {
+ public class MyBoolean {
+ public static implicit operator bool (MyBoolean x)
+ {
+ return true;
+ }
+ }
+
+ public class MyTrueFalse {
+ public static bool operator true (MyTrueFalse i)
+ {
+ return true;
+ }
+
+ public static bool operator false (MyTrueFalse i)
+ {
+ return false;
+ }
+ }
+
public class Blah {
public int i;
if (i != 0)
return 1;
+
+ MyBoolean myb = new MyBoolean ();
+
+ if (!myb)
+ return 10;
+
+ //
+ // Tests the conditional operator invoking operator true
+ MyTrueFalse mf = new MyTrueFalse ();
+ int x = mf ? 1 : 2;
+ if (x != 1)
+ return 11;
+ Console.WriteLine ("Test passed");
return 0;
}