Get Max value in int array using LINQ in CSharp

Description

The following code shows how to get Max value in int array using LINQ.

Example


  // w  w  w. j  a  v  a2s  .com

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass {
    public static void Main() {
        int[] myInts = new int[] { 974, 2, 7, 1374, 27, 54 };
        int maxInt = myInts.Max();
        Console.WriteLine(maxInt);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ