共用方式為


編譯器錯誤 CS0505

更新:2007 年 11 月

錯誤訊息

'member1': 無法覆寫,因為 'member2' 不是函式

類別宣告嘗試覆寫基底類別中的非方法項。覆寫必須符合成員型別。如果要使用與基底類別中的方法名稱相同的某方法,請在該基底類別的方法宣告上使用 new (而不用 override)。

下列範例會產生 CS0505:

// CS0505.cs
// compile with: /target:library
public class clx
{
   public int i;
}

public class cly : clx
{
   public override int i() { return 0; }   // CS0505
}