Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
interface IDeveloper
{
void LearnNewLanguage(string language, DateTime dueDate);
void LearnNewLanguage(string language)
{
// default implementation
LearnNewLanguage(language, DateTime.Now.AddMonths(6));
}
}
class BackendDev : IDeveloper // compiles OK
{
public void LearnNewLanguage(string language, DateTime dueDate)
{
// Learning new language...
}
}
class Program
{
static void Main(string[] args)
{
IDeveloper dev = new BackendDev();
dev.LearnNewLanguage("Rust"); // OK - default implementation of
// IDeveloper.LearnNewLanguage(string language) is called
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.