日期:2014-05-18 浏览次数:21770 次
List<double[]> temp = list.Select((a, i) => new double[2] { a, i }).OrderByDescending(a => a[0]).Take(3).ToList(); /* * - temp Count = 3 System.Collections.Generic.List<double[]> - [0] {double[2]} double[] [0] 19.35 double [1] 5.0 double - [1] {double[2]} double[] [0] 18.35 double [1] 3.0 double - [2] {double[2]} double[] [0] 17.35 double [1] 4.0 double */
------解决方案--------------------
List<double> list = new List<double>(); list.Add(2.55); list.Add(4.45); list.Add(12.35); list.Add(18.35); list.Add(17.35); list.Add(19.35); list.Add(6.355); list.Add(7.95); list.Add(4.35); var v = list.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).Take(1);
------解决方案--------------------
List<double> list = new List<double>();
list.Add(2.55);
list.Add(4.45);
list.Add(12.35);
list.Add(18.35);
list.Add(17.35);
list.Add(19.35);
list.Add(6.355);
list.Add(7.95);
list.Add(4.35);
var v = list.Select((m, index) => new { index, m }).OrderByDescending(n => n.m).Take(1);