Created
December 4, 2018 17:07
-
-
Save richlander/df2ad8001622135d3b71f9ce24ae081e to your computer and use it in GitHub Desktop.
Default implementations of interface members Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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