C# Error
CS0736 – ‘{0}’ does not implement instance interface member ‘{1}’. ‘{2}’ cannot implement the interface member because it is static.
Reason for the Error & Solution
‘type name’ does not implement interface member ‘member name’. ‘method name’ cannot implement an interface member because it is static.
This error is generated when a static method is either implicitly or explicitly declared as an implementation of an interface member.
To correct this error
-
Remove the modifier from the method declaration.
-
Change the name of the interface method.
-
Redefine the containing type so that it does not inherit from the interface.
Example
The following code generates CS0736 because Program.testMethod
is declared as static:
// 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() { }
}
}