Skip to content

Instantly share code, notes, and snippets.

@kg
Forked from TryJSIL/Interfaces.cs
Created April 28, 2012 09:33
Show Gist options
  • Save kg/2517477 to your computer and use it in GitHub Desktop.
Save kg/2517477 to your computer and use it in GitHub Desktop.
Interfaces
using System;
public interface I {
void Foo ();
}
public class A : I {
public void Foo () {
Console.WriteLine("A");
}
}
public class B : A, I {
void I.Foo () {
Console.WriteLine("B");
}
}
public static class Program {
public static void Main (string[] args) {
I i;
var a = new A();
i = a;
a.Foo(); // expected: "A"
i.Foo(); // expected: "A"
var b = new B();
i = b;
b.Foo(); // expected: "A"
i.Foo(); // expected: "B"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment