Errore del compilatore CS0737

Aggiornamento: novembre 2007

Messaggio di errore

'nome tipo' non implementa il membro di interfaccia 'nome membro'. 'nome metodo' non può implementare un membro di interfaccia perché è di tipo non pubblico.
'type name' does not implement interface member 'member name'. 'method name' cannot implement an interface member because it is not public.

Un metodo che implementa un membro di interfaccia deve avere accessibilità di tipo public. Tutti i membri di interfaccia sono public.

Per correggere l'errore

  • Aggiungere il modificatore di accesso public al metodo.

Esempio

Nel codice seguente viene generato l'errore CS0737:

// cs0737.cs
interface ITest
{
    int Return42();
    // Try the following line instead.
    // public int Return42();
}

struct Struct1 : ITest // CS0737
{
    int Return42() { return (42); }
}

public class Test
{
    public static int Main(string[] args)
    {
        Struct1 s1 = new Struct1();

        return (1);
    }

}

Vedere anche

Riferimenti

Interfacce (Guida per programmatori C#)