using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { int[] keys = { 31, 28, 31, 30, 31 }; string[] values = { "Jan", "Feb", "Mar", "Apr", "Jan" }; var list1 = new List>(); var list2 = new List(); Console.WriteLine("テストデータ"); for (int i = 0; i < keys.Length; i++) { list1.Add(new KeyValuePair(keys[i], values[i])); list2.Add(new Disp(keys[i], values[i])); Console.WriteLine("{0} {1}", keys[i], values[i]); } Console.WriteLine("汎用"); foreach (var disp in list1.OrderBy(t => -t.Key)) { Console.WriteLine("{0} {1}", disp.Key, disp.Value); } Console.WriteLine("独自クラス"); foreach (var disp in list2.OrderBy(t => -t.Key)) { Console.WriteLine("{0} {1}", disp.Key, disp.Value); } } class Disp { public int Key { get; set; } public string Value { get; set; } public Disp(int key, string value) { Key = key; Value = value; } } }