6 private readonly int value;
8 public integer (int value)
13 public static implicit operator integer (int i
)
15 return new integer (i
);
18 public static implicit operator double (integer i
)
20 return Convert
.ToDouble (i
.value);
23 public static integer
operator + (integer x
, integer y
)
25 return new integer (x
.value + y
.value);
31 public static object Add (integer x
, object other
)
33 if (other
is int) return x
+ ((int) other
);
34 if (other
is double) return x
+ ((double) other
);
35 throw new InvalidOperationException ();
38 public static int Main ()
40 integer i
= new integer (3);
43 object result
= Add (i
, d
);
44 if (!(result
is double))
47 if ((double) result
!= 7.0)