編譯器錯誤 CS0736
更新:2007 年 11 月
錯誤訊息
'type name' 未實作介面成員 'member name'。'method name' 無法實作介面成員,因為它是靜態的。
將靜態方法隱含或明確宣告為介面成員的實作 (Implementation) 時,會產生這個錯誤。
若要更正這個錯誤
移除方法宣告中的 static 修飾詞 (Modifier)。
變更介面方法的名稱。
重新定義包含型別 (Containing Type),讓它不要繼承自介面。
範例
因為 Program.testMethod 是宣告為靜態,所以下列程式碼會產生 CS0736:
// cs0736.cs
namespace CS0736
{
interface ITest
{
int testMethod(int x);
}
class Program : ITest // CS0736
{
public static int testMethod(int x) { return 0; }
// Try the following line instead.
// public int testMethod(int x) { return 0; }
public static void Main() { }
}
}