1 // C5 example: This should fail because C5 does not know how to build
2 // a comparer for Object.
4 // Similarly for Rec<string,int>
7 // csc /r:C5.dll TestSortedArray.cs
11 using SCG = System.Collections.Generic;
13 namespace TestSortedArray {
14 class TestSortedArray {
15 public static void Main(String[] args) {
16 // SortedArray<Object> sarr = new SortedArray<Object>();
17 SCG.IComparer<Rec<string,int>> lexico =
18 new DelegateComparer<Rec<string,int>>(
19 delegate(Rec<string,int> r1, Rec<string,int> r2) {
20 int order = r1.X1.CompareTo(r2.X1);
21 return order==0 ? r1.X2.CompareTo(r2.X2) : order;
23 SortedArray<Rec<string,int>> sarr = new SortedArray<Rec<string,int>>(lexico);
24 sarr.Add(new Rec<string,int>("ole", 32));
25 sarr.Add(new Rec<string,int>("hans", 77));
26 sarr.Add(new Rec<string,int>("ole", 63));
27 foreach (Rec<string,int> r in sarr)