Compiler Error CS0272
The property or indexer 'property/indexer' cannot be used in this context because the set accessor is inaccessible.
This error occurs when the set
accessor is not accessible to the program code.
Increase the accessibility of the accessor, or change the calling location. For more information, see Restricting Accessor Accessibility.
The following example generates CS0272:
C#
// CS0272.cs
public class MyClass
{
public int Property
{
get { return 0; }
private set { }
}
}
public class Test
{
static void Main()
{
MyClass c = new MyClass();
c.Property = 10; // CS0272
// To resolve, remove the previous line
// or use an appropriate modifier on the set accessor.
}
}
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: