How to Resolve Error "CS0683: Explicit method implementation cannot implement 'method' because it is an accessor" in C#
The Compiler Error CS0683 is a syntax error regarding Explicit Interface Implementation. The message reads: "'MyClass.Method' explicit method implementation cannot implement 'Interface.Method' because it is an accessor".
In C#, properties and events are compiled internally into "Accessor Methods" (e.g., a property int Value becomes a method int get_Value()). However, C# syntax strictly separates Properties from Methods. This error occurs when you try to implement a Property (or Event) defined in an interface by explicitly declaring a Method that matches its internal accessor name (like get_Name), instead of using the standard C# Property syntax.
This guide explains the difference between accessors and methods and how to implement interface members correctly.
Understanding Accessors vs. Methods
When you define an interface like this:
public interface IItem
{
int Id { get; }
}
The compiler internally generates a method called get_Id().
However, in C# source code, you are expected to interact with this member as a Property. You cannot treat get_Id as a normal method name during implementation. The compiler reserves that name link for the property syntax.
CS0683 happens when you try to bypass the property syntax and write the underlying method implementation manually.
Scenario: Implementing get_Name Instead of Name
This error is common when porting code from languages that don't have properties (like C++ or Java) or when a developer inspects the compiled IL code and tries to mimic the internal method names.
Example of error: the interface defines a Property Id. The class tries to implement it by defining a Method get_Id().
public interface IItem
{
// This is a Property
int Id { get; }
}
public class InventoryItem : IItem
{
// ⛔️ Error CS0683: 'InventoryItem.get_Id()' explicit method implementation
// cannot implement 'IItem.get_Id' because it is an accessor.
// The compiler knows 'IItem.get_Id' belongs to the Property 'Id'.
// It forbids you from implementing it as a standalone method.
int IItem.get_Id()
{
return 123;
}
}
Solution: Use Property Syntax
To explicitly implement a property, you must use the property syntax (curly braces with get and/or set), not method syntax (parentheses).
Solution: replace the method definition with a property definition.
public interface IItem
{
int Id { get; }
}
public class InventoryItem : IItem
{
// ✅ Correct: Using Property syntax.
// The compiler will generate the 'get_Id' method for you behind the scenes.
int IItem.Id
{
get
{
return 123;
}
}
}
Events: This logical restriction also applies to Events.
- Interface:
event EventHandler Click; - Invalid Implementation:
void IInterface.add_Click(EventHandler h) { } - Valid Implementation:
event EventHandler IInterface.Click { add { } remove { } }
Conclusion
CS0683 enforces C# syntax over internal IL representation.
- Identify the Member: Is the interface member a Property or an Event?
- Check the Syntax: Are you trying to implement it using
ReturnType Interface.MethodName()? - The Fix: Switch to Property syntax:
ReturnType Interface.PropertyName { get; set; }.