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 };
What is the simplest algorithm to use for finding the highest integer? I am using C# and the .NET 3.5 framework.
You can just do: int max = MyList. Max();
To get the smallest element, use the Min() method. list. AsQueryable(). Min();
You can just do:
int max = MyList.Max();
See Enumerable.Max for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With