Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save richlander/df2ad8001622135d3b71f9ce24ae081e to your computer and use it in GitHub Desktop.
Save richlander/df2ad8001622135d3b71f9ce24ae081e to your computer and use it in GitHub Desktop.
Default implementations of interface members Examples
interface ILogger
{
void Log(LogLevel level, string message);
void Log(Exception ex) => Log(LogLevel.Error, ex.ToString()); // New overload
}
class ConsoleLogger : ILogger
{
public void Log(LogLevel level, string message) { ... }
// Log(Exception) gets default implementation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment