Skip to content

Latest commit

 

History

History
46 lines (38 loc) · 1.13 KB

cs0272.md

File metadata and controls

46 lines (38 loc) · 1.13 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Compiler Error CS0272
Compiler Error CS0272
07/20/2015
CS0272
CS0272
16a9aab6-922a-45a3-a0ef-f32e99f3950f

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.

To correct this error

Increase the accessibility of the accessor, or change the calling location. For more information, see Restricting Accessor Accessibility.

Example

The following example generates CS0272:

// 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.  
    }  
}