日期:2014-05-17  浏览次数:20953 次

一组数据 list集合,怎么才能变成我想得到的结果
例如有这么一组数据


小明,小李,16,-7
小明,小李,16,-8
小明,小李,17,-7

小李,17,1
小李,17,2

小明,小李,小红,15,-10
小明,小李,小红,15,-9

小明,-10,18
小明,-9,18

怎么才能得到相同数据中最大的那一组数据,名字都是放在list<name>里面,只是比较这些数值,最后在这组数据中我想的到这样的效果:
小明,小李,17,-7
小李,17,2
小明,小李,小红,15,-9
小明,-9,18

-----------------------------------------------------------------------



C# code

        public Form1()
        {
            InitializeComponent();


            IList<TempNum> listTempNum = new List<TempNum>();


            TempNum tempNum1 = new TempNum();
            IList<string> listName1 = new List<string>();
            listName1.Add("小明");
            listName1.Add("小李");
            tempNum1.Num1 = 16;
            tempNum1.Num2 = -7;
            tempNum1.Count = listName1.Count;

            TempNum tempNum2 = new TempNum();
            IList<string> listName2 = new List<string>();
            listName2.Add("小明");
            listName2.Add("小李");
            tempNum2.Num1 = 16;
            tempNum2.Num2 = -8;
            tempNum2.Count = listName2.Count;

            TempNum tempNum3 = new TempNum();
            IList<string> listName3 = new List<string>();
            listName3.Add("小明");
            listName3.Add("小李");
            tempNum3.Num1 = 17;
            tempNum3.Num2 = -7;
            tempNum3.Count = listName3.Count;


            TempNum tempNum4 = new TempNum();
            IList<string> listName4 = new List<string>();
            listName4.Add("小李");
            tempNum4.Num1 = 17;
            tempNum4.Num2 = 1;
            tempNum4.Count = listName4.Count;


            TempNum tempNum5 = new TempNum();
            IList<string> listName5 = new List<string>();
            listName5.Add("小李");
            tempNum5.Num1 = 17;
            tempNum5.Num2 = 2;
            tempNum5.Count = listName5.Count;



            TempNum tempNum6 = new TempNum();
            IList<string> listName6 = new List<string>();
            listName6.Add("小明");
            listName6.Add("小李");
            listName6.Add("小红");
            tempNum6.Num1 = 15;
            tempNum6.Num2 = -10;
            tempNum6.Count = listName6.Count;

            TempNum tempNum7 = new TempNum();
            IList<string> listName7 = new List<string>();
            listName7.Add("小明");
            listName7.Add("小李");
            listName7.Add("小红");
            tempNum7.Num1 = 15;
            tempNum7.Num2 = -9;
            tempNum7.Count = listName7.Count;

            TempNum tempNum8 = new TempNum();
            IList<string> listName8 = new List<string>();
            listName8.Add("小明");
            tempNum8.Num1 = -10;
            tempNum8.Num2 = 18;
            tempNum8.Count = listName8.Count;

            TempNum tempNum9 = new TempNum();
            IList<string> listName9 = new List<string>();
            listName9.Add("小明");
            tempNum9.Num1 = -9;
            tempNum9.Num2 = 18;
            tempNum9.Count = listName9.Count;






            listTempNum.Add(tempNum1);
            listTempNum.Add(tempNum2);
            listTempNum.Add(tempNum3);
            listTempNum.Add(tempNum4); 
            listTempNum.Add(tempNum5);
            listTempNum.Add(tempNum6);
            listTempNum.Add(tempNum7);
            listTempNum.Add(tempNum8);
            listTempNum.Add(tempNum9);

            dataGridView1.DataSource = listTempNum;

        }

        public class TempNum
        {
            private int num1;

            public