Get Min value after selecting in CSharp

Description

The following code shows how to get Min value after selecting.

Example


using System;/*w ww .  j  a va 2s  .c  o m*/
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        Random generator = new Random(0);
        int[] numbers = new int[1000];
        for (int i = 0; i < 1000; i++)
        {
            numbers[i] = generator.Next();
        }
        var queryResults = from n in numbers where n > 100 select n;

        Console.WriteLine("Min of Numbers > 100");
        Console.WriteLine(queryResults.Min());

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ