Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0121 

Error Message

The call is ambiguous between the following methods or properties: 'method1' and 'method2'

Due to implicit conversion, the compiler was not able to call one form of an overloaded method. You can resolve this error in the following ways:

  • Specify the method parameters in such a way that implicit conversion does not take place.

  • Remove all overloads for the method.

  • Cast to proper type before calling method.

The following sample generates CS0121:

// CS0121.cs
public class C
   void f(int i, double d) 

   void f(double d, int i)

   public static void Main()
      C c = new C();

      c.f(1, 1);   // CS0121
      // try the following line instead
      // c.f(1, 1.0);
      // or
      // c.f(1.0, 1);
      // or
      // c.f(1, (double)1);   // cast and specify which method to call

Community Additions

© 2014 Microsoft