Compiler Error CS0531
TOC
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

Compiler Error CS0531 

Error Message

'member' : interface members cannot have a definition

Methods that are declared in an interface must be implemented in a class that inherits from it and not in the interface itself.

The following sample generates CS0531:

// CS0531.cs
namespace x
{
   public interface clx
   {
      int xclx()   // CS0531, cannot define xclx
      // Try the following declaration instead:
      // int xclx();
      {
         return 0;
      }
   }

   public class cly
   {
      public static void Main()
      {
      }
   }
}
Show:
© 2016 Microsoft