Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0273 

Error Message

The accessibility modifier of the 'property_accessor' accessor must be more restrictive than the property or indexer 'property'

The accessibility modifier of the set/get accessor must be more restrictive than the property or indexer 'property/indexer'

This error occurs when you declare a property or indexer with an access modifier that is less restrictive than the access modifier on one of its accessors. To resolve this error, use the appropriate access modifier on either the property or the set accessor. For more information, see Accessor Accessibility.

Example

This sample contains an internal property with an internal set method. The following sample generates CS0273.

// CS0273.cs
// compile with: /target:library
public class MyClass
{
   internal int Property
   {
      get { return 0; }
      internal set {}   // CS0273
      // try the following line instead
      // private set {}
   }
}

Community Additions

ADD
Show:
© 2015 Microsoft