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)
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.