共用方式為


編譯器錯誤 CS0548

更新:2007 年 11 月

錯誤訊息

'property': 屬性或索引子至少必須有一個存取子

屬性 (Property) 至少必須有一個存取子 (get 或 set) 方法。

如需詳細資訊,請參閱使用屬性 (C# 程式設計手冊)

範例

下列範例會產生 CS0548.:

// CS0548.cs
// compile with: /target:library
public class b
{
   public int MyProp {}   // CS0548

   public int MyProp2   // OK
   {
      get
      {
         return 0;
      }
      set {}
   }
}