文章内容
2017/3/7 14:28:39,作 者: 黄兵
.OrderByDescending排序
利用扩展方法OrderByDescending对数组进行降序排序
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication4{classProgram{staticvoidMain(string[] args){int[] a = { 1, 2, 3, 4, 83, 12, 232, 24, 67, 122, 12 };int[] b = a.OrderByDescending(x => x).ToArray();for(inti=0; i<b.Length;i++){Console.Write("{0} ", b[i]);}}}}
最后显示效果如下:

Enumerable.OrderByDescending 方法 :按降序对序列的元素排序,排序的依据是方法参数里的lambda表达式的值。
评论列表