Errore del compilatore CS0229

Aggiornamento: novembre 2007

Messaggio di errore

Ambiguità tra 'membro1' e 'membro2'.
Ambiguity between 'member1' and 'member2'

I membri di interfacce differenti hanno lo stesso nome. Per mantenere tali nomi è necessario qualificarli. Per ulteriori informazioni, vedere Interfacce (Guida per programmatori C#).

Nota:

In alcuni casi è possibile risolvere questa ambiguità fornendo un prefisso esplicito per l'identificatore tramite un alias using.

Esempio

Il seguente codice di esempio genera l'errore 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() {}
}