// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; public interface IX { public static abstract void M(); } public class X1 : IX { public static void M() { Console.WriteLine("X1.M"); } } public class X2 : IX { public static void M() { Console.WriteLine("X2.M"); } } public class Program { public static void Test(T o) where T : IX { T.M(); } public static void Main(string[] args) { X1.M(); X2.M(); Test(new X1()); Test(new X2()); } }