// C5 example: This should fail because C5 does not know how to build // a comparer for Object. // Similarly for Rec // Compile with // csc /r:C5.dll TestSortedArray.cs using System; using C5; using SCG = System.Collections.Generic; namespace TestSortedArray { class TestSortedArray { public static void Main(String[] args) { // SortedArray sarr = new SortedArray(); SCG.IComparer> lexico = new DelegateComparer>( delegate(Rec r1, Rec r2) { int order = r1.X1.CompareTo(r2.X1); return order==0 ? r1.X2.CompareTo(r2.X2) : order; }); SortedArray> sarr = new SortedArray>(lexico); sarr.Add(new Rec("ole", 32)); sarr.Add(new Rec("hans", 77)); sarr.Add(new Rec("ole", 63)); foreach (Rec r in sarr) Console.WriteLine(r); } } }