Compiler Error CS0277
'class' does not implement interface member 'accessor'. 'class accessor' is not public
This error occurs when you try to implement a property of an interface, but the implementation of the property accessor in the class is not public. Methods that implement interface members need to have public accessibility. To resolve, remove the access modifier on the property accessor.
Example
The following example generates CS0277:
// CS0277.cs
public interface MyInterface
{
int Property
{
get;
set;
}
}
public class MyClass : MyInterface // CS0277
{
public int Property
{
get { return 0; }
// Try this instead:
//set { }
protected set { }
}
}
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.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for