Created
May 24, 2014 13:22
-
-
Save seesharper/d3eb646540867a783e0e to your computer and use it in GitHub Desktop.
Interface riddle
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
IBar bar = new Bar(); | |
// Can you guess the output? | |
bar.Execute("TEST"); | |
} | |
} | |
public interface IFoo | |
{ | |
void Execute(string value); | |
} | |
public interface IBar : IFoo | |
{ | |
void Execute(object value); | |
} | |
public class Foo : IFoo | |
{ | |
public void Execute(string value) | |
{ | |
Console.WriteLine("Foo.Execute - string"); | |
} | |
} | |
public class Bar : IBar | |
{ | |
public void Execute(string value) | |
{ | |
Console.WriteLine("Bar.Execute - string"); | |
} | |
public void Execute(object value) | |
{ | |
Console.WriteLine("Bar.Execute - object"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment