How to Resolve Error "CS0539: Member in explicit interface declaration is not found among members of the interface that can be implemented" in C#
The Compiler Error CS0539 is an interface implementation error. The message reads: "'Member' in explicit interface declaration is not found among members of the interface that can be implemented".
In C#, Explicit Interface Implementation allows you to implement an interface method by prefixing the method name with the interface name (e.g., void IMyInterface.MyMethod()). This tells the compiler: "I am implementing MyMethod specifically for the IMyInterface contract."
This error occurs when the compiler looks at the interface definition and cannot find a member that matches the signature you wrote in your class. This is usually caused by typos, mismatched parameters, or incorrect return types.
This guide explains how to align your implementation with the interface contract.
Understanding Explicit Implementation Matching
When you write ReturnType InterfaceName.MethodName(Parameters), the compiler performs a strict lookup:
- It goes to
InterfaceName. - It looks for a member named
MethodName. - It checks if that member accepts
Parametersand returnsReturnType.
If any of these three checks fail, the compiler concludes that the member you are trying to implement does not exist on the interface, triggering CS0539.
Scenario 1: Parameter Signature Mismatch
This is the most common cause. The interface expects an int, but you implemented it with a double or a long. Even a small difference (like ref vs out) breaks the match.
Example of error
public interface ICalculator
{
// Interface expects 'int' inputs
int Add(int a, int b);
}
public class Calculator : ICalculator
{
// ⛔️ Error CS0539: 'Calculator.ICalculator.Add(double, double)' in explicit interface declaration
// is not found among members of the interface that can be implemented.
// The compiler sees we provided doubles, but the interface wants ints.
int ICalculator.Add(double a, double b)
{
return (int)(a + b);
}
}
Solution: Match Parameters Exactly
Copy the signature exactly from the interface definition.
public class Calculator : ICalculator
{
// ✅ Correct: Parameters match the interface exactly.
int ICalculator.Add(int a, int b)
{
return a + b;
}
}
Scenario 2: Return Type Mismatch
The return type is part of the signature match for explicit implementations. If the interface returns void, your implementation cannot return int.
Example of error
public interface ILogger
{
void Log(string message);
}
public class FileLogger : ILogger
{
// ⛔️ Error CS0539: The interface defines 'void Log',
// but here we try to implement 'bool Log'.
bool ILogger.Log(string message)
{
return true;
}
}
Solution: Match Return Type
Ensure the return type aligns. If you need to return extra data, you cannot do it via this specific interface member.
public class FileLogger : ILogger
{
// ✅ Correct: Matches 'void' return type.
void ILogger.Log(string message)
{
Console.WriteLine(message);
}
}
Scenario 3: Typos and Case Sensitivity
C# is case-sensitive. If the interface method is Compute, you cannot explicitly implement compute or Comput.
Example of error
public interface IWorker
{
void DoWork();
}
public class Worker : IWorker
{
// ⛔️ Error CS0539: 'IWorker' does not contain 'DoWorkk'.
// Simple typo in the name.
void IWorker.DoWorkk()
{
}
}
Solution: Verify Spelling
Use your IDE's IntelliSense to pick the correct name, or copy-paste it from the interface.
public class Worker : IWorker
{
// ✅ Correct: Spelling matches.
void IWorker.DoWork()
{
}
}
Visual Studio Tip:
If you type class Worker : IWorker, you can place your cursor on IWorker, press Ctrl + ., and select "Implement Interface Explicitly". Visual Studio will generate the correct stubs for you, avoiding all these errors.
Conclusion
CS0539 means you are claiming to implement a specific method that the interface doesn't know about.
- Check Arguments: Are you using
intinstead oflong? - Check Return Type: Are you returning
voidinstead ofbool? - Check Spelling: Did you make a typo in the method name?