Compiler Warning (level 2) CS0467

Switch View :
ScriptFree
Visual C# Reference: Errors and Warnings
Compiler Warning (level 2) CS0467

Ambiguity between method 'method' and non-method 'non-method'. Using method group.

Inherited members with same signature, from different interfaces, cause ambiguity error.

Example

The following example generates CS0467.

// CS0467.cs
interface IList 
{
int Count { get; set; }
}
interface ICounter
{
void Count(int i);
}

interface IListCounter : IList, ICounter {}

class Driver 
{
    void Test(IListCounter x)
    {
        x.Count = 1;
        x.Count(1);   // CS0467
        // To resolve change the method name "Count" to another name.
    }
    
    static void Main() 
    {
    }
}
See Also

Tasks

Community Content

Marko Parkkola
Microsoft.Office.Interop.Word.Quit(..)
Here's a way to get rid of that warning allthought the warning is pretty silly to me. How there can be any ambiguity since I can't trigger events directly outside the class?

((Microsoft.Office.Interop.Word.

_Application)wordApp).Quit(ref False, ref missing, ref missing);

SJ at MSFT
definitely.
Yeah it's great that you can resolve the error by changing method names, but what if you didn't write the class? right now I'm working with the

Microsoft.Office.Interop.Word close method and there's no way to rewrite it.

ANSWER:
You can create an object of a necessary interface. For example, this is how you can resolve this error without changing the method name:

void Test(IListCounter x)

{

IList list = x;

list.Count = 1;


ICounter counter = x;

counter.Count(1);

}


JoeBuddha
LAME
This is the LAMEST warning ever. If I'm using a name as a METHOD, why would there be any ambiguity? Var figures out what you want from context, after all.