// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; public interface AnyC { void doit(); } public class C1 : AnyC { public void doit() { Console.WriteLine("I am a 1"); } } public class C2 : AnyC { public void doit() { Console.WriteLine("I am a 2"); } } public class Tester { private AnyC c; public Tester(AnyC c) { this.c = c; } public void test() { c.doit(); } } class MainClass { public static void Main(string[] args) { Tester t1 = new Tester(new C1()); t1.test(); Tester t2 = new Tester(new C2()); t2.test(); } }