コード例 #1
0
        //
        static void SortAndShowList(Food[] list)
        {
            Array.Sort(list, FoodNameComparer.Instanse());

            foreach (var item in list)
            {
                Console.WriteLine(item);
            }
        }
コード例 #2
0
        //
        private static void FoodInstancesComparison()
        {
            Food[] list =
            {
                new Food("orange", FoodType.Fruit),
                new Food("banana", FoodType.Fruit),
                new Food("pear",   FoodType.Fruit),
                new Food("apple",  FoodType.Fruit),
            };

            Array.Sort(list, FoodNameComparer.Instanse());

            foreach (var item in list)
            {
                Console.WriteLine(item);
            }
        }