fork download
  1. using System;
  2. struct Dt {
  3. byte v;
  4. public Dt(byte v) {
  5. if (v > 9) throw new ArgumentException();
  6. this.v = v; }
  7. public static implicit operator byte(Dt d) {
  8. Console.Write( "1 - ");
  9. return d.v; }
  10. public static implicit operator short(Dt d) {
  11. Console.Write( "2 - " ); return d.v; } }
  12. class Test {
  13. public static void Main() {
  14. Dt d = new Dt(9);
  15. byte b = d;
  16. short c = d;
  17. Console.WriteLine("{0} {1}",b,c);
  18. } }
Success #stdin #stdout 0.03s 37024KB
stdin
Standard input is empty
stdout
1 - 2 - 9 9