What are default interface methods and when are they useful?
Short answer
Since C# 8 an interface can provide a default method body, letting you add members to an interface without breaking existing implementers.
Advertisement
AModel answer
Since C# 8 an interface can provide a default method body, letting you add members to an interface without breaking existing implementers.
interface ILogger { void Log(string m); void LogError(string m) => Log("ERR: "+m); }Real-world example
Extending a widely-implemented library interface without forcing every implementer to change.