Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions docs/csharp/misc/cs0121.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,50 @@ ms.assetid: 316cb77e-a500-4129-ae1b-e68b9188fd3e

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:
Due to implicit conversion, the compiler was not able to call one form of an overloaded method. You can resolve this error in one of 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 the method.
- Use named arguments.

## Examples
## Example

The following examples generate compiler error CS0121:

```csharp
public class C
public class Program
{
void f(int i, double d)
{
}

void f(double d, int i)
{
}

public static void Main()
{
C c = new C();
static void f(int i, double d)
{
}

c.f(1, 1); // CS0121
static void f(double d, int i)
{
}

// Try the following code 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.
}
public static void Main()
{
f(1, 1); // CS0121

// Try the following code instead:
// f(1, 1.0);
// or
// f(1.0, 1);
// or
// f(1, (double)1); // Cast and specify which method to call.
// or
// f(i: 1, 1);
// or
// f(d: 1, 1);

// f(i: 1, d: 1); // This still gives CS0121
}
}
```

## Example

```csharp
class Program2
{
Expand Down