C# Queryable Min Method


Get the minimum value from a sequence using the Min() method in C#.

The following is our list.

List<long> list = new List<long> { 1, 2, 3, 4, 5, 6 };

Now, use Queryable Min() method to get minimum element.

list.AsQueryable().Min();

Example

using System;
using System.Collections.Generic;
using System.Linq;
class Demo {
   static void Main() {
      List<long> list = new List<long> { 1, 2, 3, 4, 5, 6 };
      foreach(long ele in list) {
         Console.WriteLine(ele);
      }
      // getting lowest element
      long min_num = list.AsQueryable().Min();
      Console.WriteLine("Smallest number = {0}", mix_num);
   }
}

Updated on: 23-Jun-2020

77 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements