Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0274

Cannot specify accessibility modifiers for both accessors of the property or indexer 'property/indexer'

This error occurs when you declare a property or indexer with access modifiers on both its accessors. To resolve this error, use an access modifier on only one of the two accessors. For more information, see Accessor Accessibility.

The following example generates CS0274:

// CS0274.cs
public class MyClass
{
    public int Property   // CS0274
    {
        public get { return 0; }
        protected set { }
    }
}

Community Additions

ADD
Show:
© 2014 Microsoft