Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
interface IDeveloper
{
void LearnNewLanguage(string language)
{
Console.Write($"Learning {language} in a default way.");
}
}
interface IBackendDev : IDeveloper
{
void LearnNewLanguage(string language)
{
Console.Write($"Learning {language} in a backend way.");
}
}
interface IFrontendDev : IDeveloper
{
void LearnNewLanguage(string language)
{
Console.Write($"Learning {language} in a frontend way.");
}
}
interface IFullStackDev : IBackendDev, IFrontendDev { } // uses default implementation,
// of LearnNewLanguage, but which one?
class Dev : IFullStackDev { }
class Program
{
static void Main(string[] args)
{
IFullStackDev dev = new Dev();
dev.LearnNewLanguage("TypeScript"); // which method is called? The one
// from IBackendDev or IFrontendDev?
}
}
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.