In this article we will learn, how to use LINQ Max() Function or what is LINQ Max() Function C# Mvc with example.



In LINQ, The Max() Function gives us the maximum value from a collection or List. It is use to get the maximum value from given collection or List. LINQ has made it very easy to find the maximum value from a given data collection or List. Otherwise in our normal coding we have to write quite bit of code to get maximum value from list of available values.

LINQ Max() Function Example

Now we will see the complete example of using linq Max() function to get minimum value from the list in C#.


using System;
using System.Collections.Generic;
using System.Linq;
namespace SQLTutorialsPoint
    class Program
        static void Main(string[] args)
            int[] Num = { 10, 20, 30, 40, 50, 60, 70, 80, 90 };
            Console.WriteLine("The Minimum value in the given array is:");
            int minimumNum = Num.Min();
            Console.WriteLine("The minimum Number is {0}", minimumNum);

When we execute above c# program, we will get the result like as shown below.

how to use Max function in linq c#

As you see above example we have a integer array “Num” and we will find maximum value from the given array using LINQ Max() function


I hope it will help to you after reading.



Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like