Created
May 18, 2018 15:41
-
-
Save Keboo/8d17a38ff2f30cf50d21dfc37d80efa3 to your computer and use it in GitHub Desktop.
Replace explicit interface implementation.
This file contains hidden or 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
//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