編譯器錯誤 CS0737
更新:2007 年 11 月
錯誤訊息
'type name' 未實作介面成員 'member name'。'method name' 無法實作介面成員,因為它不是公用的。
實作介面成員的方法必須要有公用 (Public) 存取範圍。所有介面成員都是 public。
若要更正這個錯誤
- 將 public 存取修飾詞 (Modifier) 加入至方法。
範例
下列程式碼會產生 CS0737:
// cs0737.cs
interface ITest
{
int Return42();
// Try the following line instead.
// public int Return42();
}
struct Struct1 : ITest // CS0737
{
int Return42() { return (42); }
}
public class Test
{
public static int Main(string[] args)
{
Struct1 s1 = new Struct1();
return (1);
}
}