Numeric Aggregates: Min : Min « LINQ « C# / CSharp Tutorial






using System;
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());

        }
    }








22.55.Min
22.55.1.First Min Prototype
22.55.2.Min with string value
22.55.3.Min with object property
22.55.4.Min with string property value
22.55.5.Using Min to get the lowest number in an integer array.
22.55.6.Using Min to get the length of the shortest word in a string array.
22.55.7.Grouped Min
22.55.8.Numeric Aggregates: Min