Array.Sort(valuesArry);
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication5 { class Program { static void Main(string[] args) { double[] valuesArry = new double[] { 2.69542810293899, 8.67362626166823, 8.714769350604, 4.76212713707014 }; Array.Sort(valuesArry); for (int i = 0; i < 4;i++ ) { Console.WriteLine("{0}", valuesArry[i]); } Console.WriteLine("========================="); Console.WriteLine("{0}", valuesArry[valuesArry.Length/2]); Console.WriteLine("{0}", valuesArry[(valuesArry.Length+1) / 2-1]); /* 2.69542810293899 4.76212713707014 8.67362626166823 8.714769350604 ========================= 8.67362626166823 4.76212713707014 请按任意键继续. . . */ } } }