Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Created July 2, 2013 04:36
Show Gist options
  • Select an option

  • Save davidfowl/5906798 to your computer and use it in GitHub Desktop.

Select an option

Save davidfowl/5906798 to your computer and use it in GitHub Desktop.
Compiler bug with dynamic and interface inheritance
namespace CompilerBug
{
public interface IFoo : IBar
{
}
public interface IBar
{
void Bar(string name);
}
public class Foo : IFoo
{
public void Bar(string name)
{
Console.WriteLine("Hello World");
}
}
private static void WorkingDynamic()
{
Foo foo = new Foo();
dynamic d = "test";
foo.Bar(d);
}
private static void BrokenDynamic()
{
IFoo foo = new Foo();
dynamic d = "test";
foo.Bar(d);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment