Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error CS0545 

Error Message

'function' : cannot override because 'property' does not have an overridable get accessor

An attempt was made to define an override for a property accessor when the base class has no such definition to override. You can resolve this error by:

  • Adding a set accessor in the base class.

  • Removing the set accessor from the derived class.

  • Hiding the base class property by adding the new keyword in derived class's property.

  • Making the base class property virtual.

For more information, see Using Properties (C# Programming Guide) and Using Properties (C# Programming Guide).

Example

The following sample generates CS0545.

// CS0545.cs
// compile with: /target:library
// CS0545
public class a
{
   public virtual int i
   {
      set {}

      // Uncomment the following line to resolve.
      // get { return 0; }
   }
}

public class b : a
{
   public override int i
   {
      get { return 0; }
      set {}   // OK
   }
}

Community Additions

ADD
Show:
© 2015 Microsoft