Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0229

Ambiguity between 'member1' and 'member2'

Members of different interfaces have the same name. If you want to keep the same names, you must qualify the names. For more information, see Interfaces (C# Programming Guide).

Note Note

In some cases, this ambiguity can be resolved by providing an explicit prefix to the identifier via a using alias.

The following example generates CS0229:

// CS0229.cs

interface IList
{
    int Count
    {
        get;
        set;
    }

    void Counter();
}

interface Icounter
{
    double Count
    {
        get;
        set;
    }
}

interface IListCounter : IList , Icounter {}

class MyClass
{
    void Test(IListCounter x)
    {
        x.Count = 1;  // CS0229
        // Try one of the following lines instead:
        // ((IList)x).Count = 1;
        // or
        // ((Icounter)x).Count = 1;
    }

    public static void Main() {}
}
Show:
© 2014 Microsoft