public static void Main()
 {
     NewOrderedName jAdams = new NewOrderedName("John", "Adams");
     NewOrderedName jqAdams =
                    new NewOrderedName("John", 'Q', "Adams");
     NewOrderedName hAdams =
                        new NewOrderedName("Henry", "Adams");
     Console.WriteLine
        ("jAdams vs. jqAdams {0}", jAdams.CompareTo(jqAdams));
     Console.WriteLine
        ("jAdams vs. hAdams {0}", jAdams.CompareTo(hAdams));
     Console.WriteLine
        ("hAdams vs. hAdams {0}", hAdams.CompareTo(hAdams));
 }
Exemple #2
0
 public static void Main()
 {
     SortedDictionary<NewOrderedName, int> list = new SortedDictionary<NewOrderedName, int>();
     NewOrderedName jackson, madison;
     list.Add(new NewOrderedName("George", "Washington"), 67);
     list.Add(new NewOrderedName("John", "Adams"), 90);
     list.Add(new NewOrderedName("Thomas", "Jefferson"), 83);
     list.Add
        (madison = new NewOrderedName("James", "Madison"), 85);
     list.Add(new NewOrderedName("James", "Monroe"), 73);
     list.Add(new NewOrderedName("John", 'Q', "Adams"), 80);
     list.Add
        (jackson = new NewOrderedName("Andrew", "Jackson"), 78);
     list.Add(new NewOrderedName("Martin", "Van Buren"), 79);
     list.Add
      (new NewOrderedName("William", 'H', "Harrison"), 68);
     list.Add(new NewOrderedName("John", "Tyler"), 71);
     foreach(KeyValuePair<NewOrderedName, int> entry in list)
       Console.Write("{0} ", entry.Key);
 }