// testing polylists.dll routines using System; public class polyuse { public static void Main() { cell I = new cell(new integer(2), new cell(new integer(5),null)); cell R = new cell(new rational(1,2), new cell(new rational(1,4),null)); Console.WriteLine(I.length()); Console.WriteLine(I.sum()); Console.WriteLine(R.sum()); cell S = new cell(new str("hello"), new cell(new str(" world"),null)); Console.WriteLine(S.sum()); } // Main } // compile with csc polyuse.cs /r:polylists.dll //// Important: I can extend the definition without creating inconsistencies // add new class for strings public class str : addable { string s; public str(string a) {s=a;} public str add(str B) { return new str(s+B.s); } public override string ToString() { return s; } }