Compiler Error CS0531
'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:
C#
// 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()
{
}
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: