Search⌘ K

Violation of the Liskov Substitution Principle

Explore how the Liskov Substitution Principle guides the use of inheritance and method overriding in C#. Understand when overriding virtual methods may violate this principle, and how to apply it wisely to maintain reliable and predictable code behavior.

Applying the Liskov substitution principle to C# virtual methods

The Liskov substitution principle is a pattern of coding that’ll help prevent unintended functionality from being introduced into the code when we extend existing classes via inheritance.

However, certain language features might give less experienced developers the impression ...