Edit

Share via


Compiler error CS0273

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 the accessibility of the accessor you declared isn't less restrictive than the accessibility of the property or indexer.

To correct this error

Use the appropriate access modifier on either the property or the accessor. For more information, see Restricting Accessor Accessibility and Accessors.

Example

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

C#
// 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 {}
   }
}