Skip to main content

How to Resolve Error "CS0545: cannot override because 'property' does not have an overridable get accessor" in C#

The Compiler Error CS0545 is an inheritance constraint error. The message reads: "'Child.Property': cannot override because 'Parent.Property' does not have an overridable get accessor".

In C#, properties are composed of two distinct methods: a getter (get) and a setter (set). When you override a property, you can only override the specific accessors that exist and are accessible in the base class. This error occurs when you try to define a get accessor in an override property, but the base class property either does not have a getter, or its getter is not marked as virtual (or abstract), or it is effectively hidden (private).

This guide explains how property overriding works and how to resolve accessor mismatches.

Understanding Property Accessor Inheritance

When you override a property:

public override int Value { get; set; }

You are actually instructing the compiler to override two underlying methods: get_Value() and set_Value().

To succeed, the base class must provide a corresponding virtual hook for both. If the base class defines Value as Write-Only (it has set but no get), there is no get_Value method in the base virtual table to override. Consequently, your child class cannot declare a get block marked as override.

Scenario 1: Overriding a Write-Only Property

This happens when the base property was designed to only accept data (like a configuration setter), but the derived class tries to make it readable.

Example of error

public class BaseLogger
{
// Write-only property (No getter)
public virtual string LogMessage
{
set { System.Console.WriteLine(value); }
}
}

public class FileLogger : BaseLogger
{
private string _msg;

// ⛔️ Error CS0545: 'FileLogger.LogMessage': cannot override because
// 'BaseLogger.LogMessage' does not have an overridable get accessor.
public override string LogMessage
{
get { return _msg; } // There is nothing in the base to override here.
set { _msg = value; }
}
}

Solution: Do Not Override the Getter

You can override the setter (since it exists in the base), but you cannot introduce a getter via override.

If you absolutely need a getter, you must create a new property (Shadowing) or redesign the base class.

Option A: Override only what exists

public class FileLogger : BaseLogger
{
public override string LogMessage
{
// ✅ Correct: Only overriding the setter
set { base.LogMessage = value; }
}
}

Option B: Use new to redefine the property completely

public class FileLogger : BaseLogger
{
private string _msg;

// ✅ Correct: 'new' creates a brand new property with both get and set.
// Note: Polymorphism breaks here (BaseLogger references won't see the getter).
public new string LogMessage
{
get { return _msg; }
set { _msg = value; }
}
}

Scenario 2: The Base Getter is Not Virtual

Sometimes the base property has a getter, but it is not marked as virtual. You cannot override a specific accessor if the parent didn't opt-in to polymorphism for it.

Example of error

public class Account
{
// The property is virtual, but logic might be split
public virtual int ID
{
get { return 1; } // Implicitly virtual because of property declaration
set { }
}
}

// However, if the base defined it oddly:
public class WeirdAccount
{
public int ID { get; virtual set; } // Only SET is virtual
}

public class MyAccount : WeirdAccount
{
// ⛔️ Error CS0545: The base 'get' is not virtual, so we can't override it.
public override int ID
{
get { return 2; }
set { base.ID = value; }
}
}

Solution: Update the Base Class

Ensure the entire property in the base class is marked virtual, which applies to both accessors.

public class WeirdAccount
{
// ✅ Correct: Apply virtual to the whole property
public virtual int ID { get; set; }
}

public class MyAccount : WeirdAccount
{
// ✅ Correct: Now we can override both
public override int ID
{
get { return 2; }
set { base.ID = value; }
}
}

Solution: Match the Base Accessors

When overriding, you generally cannot add accessors that didn't exist in the virtual definition. You must match the "shape" of the parent property.

  1. If Base has get: Override get.
  2. If Base has set: Override set.
  3. If Base lacks get: You cannot write get in the override.
public class Parent
{
public virtual int Value { set { } }
}

public class Child : Parent
{
// ✅ Correct: Matching the Write-Only nature
public override int Value
{
set { System.Console.WriteLine("Set in child"); }
}
}

Conclusion

CS0545 enforces the structure of inheritance.

  1. Check the Base: Does the parent property actually have a get accessor?
  2. Check Virtual: Is that get accessor explicitly or implicitly virtual?
  3. Align: If the base is write-only, your override must be write-only. If you need read-write, use new to hide the base property or modify the base class.