查找最高整数泛型列表使用C#? [英] Find highest integer in a Generic List using C#?

查看:133
本文介绍了查找最高整数泛型列表使用C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下的名单,其中,INT> 收集和我需要找到集合中的最大整数。它可能有一个整数的任意号码,我可以有多次相同的整数值。

I have the following List<int> collection and I need to find the highest integer in the collection. It could have an arbitrary number of integers and I can have same integer value for multiple times.

List<int> MyList = new List<int> { 3, 4, 6, 7, 9, 3, 4, 5, 5 };

这是用于查找的最大整数的最简单的算法?我使用C#和.NET 3.5框架。

What is the simplest algorithm to use for finding the highest integer? I am using C# and the .NET 3.5 framework.

推荐答案

您可以这样做:

int max = MyList.Max();

请参阅 Enumerable.Max 了解详细信息。

这篇关于查找最高整数泛型列表使用C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆