This documentation is archived and is not being maintained.

Compiler Error CS0545

'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.

The following sample generates CS0545:

// CS0545.cs
namespace x
{
   public class a
   {
      public virtual int i
      {
         set
         {
         }
         // uncomment this accessor to resolve CS0545
         // get
         // {
         //   return 0;
         // }
      }
   }

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

      public static void Main()
      {
      }
   }
}

See Also

Property Declaration | Accessors

Show: