閱讀英文

共用方式為


編譯器錯誤 CS0737

'type name' 未實作介面成員 'member name'。 'method name' 無法實作介面成員,因為它不是公用的。

實作介面成員的方法必須具有公用存取範圍。 所有介面成員都是 public

更正這個錯誤

  1. 公用 存取修飾詞加入方法中。

範例

下列程式碼會產生 CS0737:

C#
// cs0737.cs  
interface ITest  
{  
    // Default access of private with no modifier.  
    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);  
    }  
  
}  

另請參閱