HomeCSharpC# Error CS0736 – ‘{0}’ does not implement instance interface member ‘{1}’. ‘{2}’ cannot implement the interface member because it is static.

C# Error CS0736 – ‘{0}’ does not implement instance interface member ‘{1}’. ‘{2}’ cannot implement the interface member because it is static.

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() { }  
    }
}  

Leave A Reply

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

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...