public static implicit operator int (Blah i)
{
- Console.WriteLine ("Converting from Blah->int");
+ Console.WriteLine ("Blah->int");
return 3;
}
+ public static implicit operator byte (Blah i)
+ {
+ Console.WriteLine ("Blah->byte");
+ return 0;
+ }
+
+ public static implicit operator short (Blah i)
+ {
+ Console.WriteLine ("Blah->short");
+ return 1;
+ }
+
}
public class Foo : Blah {
int number = new Foo () + new Foo () ;
Console.WriteLine (number);
- int k = new Foo ();
+ Foo tmp = new Foo ();
+
+ int k = tmp;
+
+ Console.WriteLine ("Convert from Foo to float");
+ float f = tmp;
+ Console.WriteLine ("Converted");
+
+ // The following will not work till we fix our UserCast::Emit
+ // to convert the return value on the stack.
+ if (f == 3)
+ Console.WriteLine ("Best implicit conversion selected correctly.");
+
+ Console.WriteLine ("F is {0}", f);
if (number == 2 && k == 3)
return 0;