// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; namespace Dynamic { public interface ITest { void Test(); } public class TestImpl : ITest { private IIntMath im; private IDoubleMath dm; public TestImpl(IIntMath im, IDoubleMath dm) { this.im = im; this.dm = dm; } public void Test() { Console.WriteLine("Start"); try { Console.WriteLine("2+3=" + im.Add(2, 3)); Console.WriteLine("2.0*3.0=" + dm.Multiply(2.0, 3.0)); Console.WriteLine("10/0=" + im.Divide(10, 0)); } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); } Console.WriteLine("End"); } } }