Skip to content

Instantly share code, notes, and snippets.

@seesharper
Created May 24, 2014 13:22
Show Gist options
  • Save seesharper/d3eb646540867a783e0e to your computer and use it in GitHub Desktop.
Save seesharper/d3eb646540867a783e0e to your computer and use it in GitHub Desktop.
Interface riddle
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