Tag .NET
IEnumerable interface in .NET and LSP
I often see developers saying that in most cases, use of IEnumerable breaks LSP. Does it? Let’s find out. This is the continuation of my article Read-Only Collections and LSP. It this post, I’d like to discuss IEnumerable interface from a Liskov Substitution Principle (LSP) perspective. Liskov Substitution Principle and IEnumerable interface To answer the question whether or not use of IEnumerable breaks LSP, we should step back and see what it means to break LSP.
C# Read-Only Collections and LSP
I often see programmers saying that .NET read-only collections violate Liskov Substitution Principle. Do they? The quick answer is no but let’s go through the whole story first.
1