C# Error CS0737 – ‘{0}’ does not implement interface member ‘{1}’. ‘{2}’ cannot implement an interface member because it is not public.

C# Error

CS0737 – ‘{0}’ does not implement interface member ‘{1}’. ‘{2}’ cannot implement an interface member because it is not public.

Reason for the Error & Solution

‘type name’ does not implement interface member ‘member name’. ‘method name’ cannot implement an interface member because it is not public.

A method that implements an interface member must have public accessibility. All interface members are public.

To correct this error

  1. Add the access modifier to the method.

Example

The following code generates CS0737:

// 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);  
    }  
  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...