// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; namespace E { public interface I1 { } public interface I2 : I1 { } public class C : I2 { } public static class MyExtensions { public static void M(this I1 o) { Console.WriteLine("I1.M"); } public static void M(this I2 o) { Console.WriteLine("I2.M"); } public static void M(this C o) { Console.WriteLine("C.M"); } } public class Program { public static void Main(string[] args) { I1 o1 = new C(); o1.M(); I2 o2 = new C(); o2.M(); C o3 = new C(); o3.M(); } } }