編譯器錯誤 CS0274
更新:2007 年 11 月
錯誤訊息
不能同時對屬性或索引子 'property/indexer' 的兩種存取子指定存取範圍修飾詞
當您宣告屬性 (Property) 或索引子 (Indexer),而在其兩種存取子 (Accessor) 上使用存取修飾詞時,便會發生這個錯誤。若要解決這個錯誤,請只在其中一個存取子上使用存取修飾詞。如需詳細資訊,請參閱存取子存取範圍。
下列範例會產生 CS0274:
// CS0274.cs
public class MyClass
{
public int Property // CS0274
{
public get { return 0; }
protected set { }
}
}