void Main()
    {
        MyAdder myAdder = new MyAdder();

        // Even though ICanAdd is not implemented by MyAdder,
        // we can duck cast it because it implements all the members:
        ICanAdd adder = DuckTyping.Cast <ICanAdd>(myAdder);

        // Now we can call adder as you would any ICanAdd object.
        // Transparently, this call is being forwarded to myAdder.
        int sum = adder.Add(2, 2);
    }
Exemple #2
0
 public void MyAdderTestSimple()
 {
     Assert.AreEqual(MyAdder.Add(1, 2), 3);
 }