Skip to content

Instantly share code, notes, and snippets.

@Keboo
Created May 18, 2018 15:41
Show Gist options
  • Save Keboo/8d17a38ff2f30cf50d21dfc37d80efa3 to your computer and use it in GitHub Desktop.
Save Keboo/8d17a38ff2f30cf50d21dfc37d80efa3 to your computer and use it in GitHub Desktop.
Replace explicit interface implementation.
//https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/interfaces#interface-implementation-inheritance
class Program
{
static void Main(string[] args)
{
IFoo @base = new Base();
IFoo derived = new Derived();
Console.WriteLine(@base.Bar()); //=> Base
Console.WriteLine(derived.Bar()); //=> Derived
Console.ReadLine();
}
}
public interface IFoo
{
string Bar();
}
public class Base : IFoo
{
string IFoo.Bar() => "Base";
}
public class Derived : Base, IFoo
{
string IFoo.Bar() => "Derived";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment