Exemple #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            ListGog          listdog = new ListGog();
            List <DogEntity> list    = listdog.GetListDog();

            ///使用委托排序 ,最后生成 list.Sort(new Comparison<DogEntity>(this.ComparisonDog));
            list.Sort(ComparisonDog);

            foreach (var p in list)
            {
                Console.WriteLine(p.Age + ":" + p.Name);
            }
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            ListGog          listdog  = new ListGog();
            List <DogEntity> list     = listdog.GetListDog();
            DogSrot          comparer = new DogSrot();

            list.Sort(comparer);  //接口实现排序

            foreach (var p in list)
            {
                Console.WriteLine(p.Age + ":" + p.Name);
            }
        }