Skip to main content
An overridden property in C# allows a derived class to replace or extend the implementation of a property inherited from a base class. To enable this mechanism, the base class property must be explicitly marked with the virtual, abstract, or override modifier, and the derived class must declare the property using the override keyword with an identical signature.

Compiler Rules and Constraints

To successfully override a property, the C# compiler enforces strict structural rules:
  • Signature Matching: The overriding property must have the exact same name and data type as the inherited base property.
  • Modifier Prerequisites: You cannot override a standard (non-virtual) property. The base property must be virtual, abstract, or an already overridden property (override). It cannot be static.
  • Accessibility Parity: The access modifier of the overriding property must exactly match the base property (e.g., a protected virtual property must be overridden as protected override).
  • Accessor Limitations: A derived class cannot add new accessors. If the base property is read-only (only has a get accessor), the overriding property cannot introduce a set accessor.
  • Asymmetric Accessor Modifiers: If the base property defines different access levels for its accessors (e.g., a public property with a protected set), the overriding accessors implicitly inherit those exact accessibility levels. You must omit the access modifier in the derived class (e.g., writing set { ... }). Explicitly applying an access modifier to an overridden accessor results in compiler error CS0275 (accessibility modifiers may not be used on accessors in an override).

Accessing the Base Implementation

When overriding a virtual property, the derived class can invoke the parent class’s property accessors using the base keyword. This is strictly used to extend, rather than completely replace, the base logic. Abstract properties do not have a base implementation to call.

Sealing an Overridden Property

If a property is overridden, it remains virtual to any further derived classes. To terminate the inheritance chain and prevent deeper subclasses from overriding the property again, apply the sealed modifier alongside override.

Covariant Return Types (C# 9.0+)

Starting with C# 9.0, overridden read-only properties support covariant return types. This means the overriding property can declare a return type that is more derived (more specific) than the return type declared in the base property.
Tired of Poor C# Skills? Fix That With Deep Grasping!Learn More