如何获得第二高的数字在Visual C#中的数组? [英] How to get the second highest number in an array in Visual C#?
本文介绍了如何获得第二高的数字在Visual C#中的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有int数组。我想获得的第二高数量的数组。有没有一种简单的方法来做到这一点?
I have an array of ints. I want to get the second highest number in that array. Is there an easy way to do this?
推荐答案
试试这个(使用LINQ):
Try this (using LINQ):
int secondHighest = (from number in numbers
orderby number descending
select number).Skip(1).First();
这篇关于如何获得第二高的数字在Visual C#中的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文