How to find the maximum and minimum number in a List in C# – Programming, Pseudocode Example, C# Programming Example
C# C# Console Collection List

How to find the maximum and minimum number in a List in C#

In this blog post, I will be demonstrating how you can find the largest and smallest number in an array. Consider the following code snippet:

C# Code:

This code uses the Max and Min methods. The Collections class contains static utility methods that operate on collections like List, Set etc.

The Max() method returns the greatest element in the list according to the natural order or sorting.

Similarly, the Min() returns the smallest element in the list according to the natural order of sorting. When this code is executed, it will print the following output:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.