C# Program to find the largest element from an array

CsharpProgrammingServer Side Programming

Declare an array −

int[] arr = { 20, 50, -35, 25, 60 };

Now to get the largest element from an array, use the Max() method −

arr.Max());

Here is the complete code −

Example

 Live Demo

using System;
using System.Linq;
class Demo {
   static void Main() {
      int[] arr = { 20, 50, -35, 25, 60 };
      Console.WriteLine(arr.Max());
   }
}

Output

60
raja
Published on 05-Sep-2018 10:33:45
Advertisements