C# Feature - Default interface methods
Overview
Section titled “Overview”Default interface methods allow interfaces to provide method bodies, which helps evolve contracts without breaking every implementation.
Introduced In
Section titled “Introduced In”C# 8.0 (2019)
Before
Section titled “Before”public interface ILogger{ void Log(string message);}public interface ILogger{ void Log(string message); void LogError(string message) => Log($"ERROR: {message}");}Gotchas & Best Practices
Section titled “Gotchas & Best Practices”- Use this for interface evolution, not as a replacement for good abstraction design.
- Keep default implementations small and unsurprising.