-// cs0121-3.cs: The call is ambigious between `IInteger.Add (int)' and `IDouble.Add (double)'
-// Line: 28
+// CS0121: The call is ambiguous between the following methods or properties: `A.operator +(A, B)' and `B.operator +(A, B)'
+// Line: 21
-// (note, this is taken from `13.2.5 Interface member access')
-interface IInteger {
- void Add(int i);
-}
-
-interface IDouble {
- void Add(double d);
-}
-
-interface INumber: IInteger, IDouble {}
-
-class Number : INumber {
- void IDouble.Add (double d)
+class A
+{
+ public static A operator + (A a, B b)
{
- System.Console.WriteLine ("IDouble.Add (double d)");
+ return null;
}
- void IInteger.Add (int d)
+}
+
+class B
+{
+ public static A operator + (A a, B b)
{
- System.Console.WriteLine ("IInteger.Add (int d)");
+ return null;
}
-
+
static void Main ()
{
- INumber n = new Number ();
- n.Add(1); // Error, both Add methods are applicable
- n.Add(1.0); // Ok, only IDouble.Add is applicable
- ((IInteger)n).Add(1); // Ok, only IInteger.Add is a candidate
- ((IDouble)n).Add(1); // Ok, only IDouble.Add is a candidate
+ object o = new A () + new B ();
}
-}
\ No newline at end of file
+}