(原创) C# List 找 Max 的 Index

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ListMethod
{
    class Program
    {
        static void Main(string[] args)
        {
            List<double> c = new List<double>();
            c.Add(1);
            c.Add(4);
            c.Add(2);
            c.Add(3);

            List<double> temp = new List<double>();
            foreach (double elementInC in c)
            {
                temp.Add(elementInC);
            }

            temp.Sort();
            temp.Reverse();
            double max = temp[0];

            int i = c.FindIndex(0, delegate(double p) { return p == max; }); 
        }
    }
}

 

posted on 2016-04-19 20:36  jamey  阅读(536)  评论(0)    收藏  举报