Compiler Error CS0276
'property/indexer': accessibility modifiers on accessors may only be used if the property or indexer has both a get and a set accessor
This error occurs when you declare a property or indexer with one accessor only, and use an access modifier on the accessor. To resolve, remove the access modifier or add another accessor.
The following example generates CS0276:
// CS0276.cs
public class MyClass
{
public int Property
{
protected set { } // CS0276
}
public int Property2
{
internal get { } // CS0276
}
}
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: