共用方式為


編譯器錯誤 CS0277

更新:2007 年 11 月

錯誤訊息

'class' 未實作介面成員 'accessor'。'class accessor' 不是公用的。

當您嘗試實作介面的屬性 (Property),但類別中屬性存取子 (Accessor) 的實作不是公用的,便會發生這個錯誤。實作介面成員的方法必須有公用存取範圍。若要解決問題,請移除屬性存取子的存取修飾詞。

範例

下列範例會產生 CS0277:

// CS0277.cs
public interface MyInterface
{
    int Property
    {
        get;
        set;
    }
}

public class MyClass : MyInterface   // CS0277
{
    public int Property
    {
        get { return 0; }
        // Try this instead:
        //set { }
        protected set { }
    }
}