C# Program to find the smallest element from an array

CsharpProgrammingServer Side Programming

Declare an array −

int[] arr = { 5, 9, 2, 7 };

Now to get the smallest element from an array, use the Min() method −

arr.Min());

Here is the complete code −

Example

 Live Demo

using System;
using System.Linq;
class Demo {
   static void Main() {
      int[] arr = { 5, 9, 2, 7 };
      Console.WriteLine(arr.Min());
   }
}

Output

2
raja
Published on 04-Sep-2018 14:09:29
Advertisements