Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

Enumerable.Min: practical reference

Enumerable.Min: practical reference: Immediately enumerates and selects the smallest value or smallest selector result under the appropriate comparer.

Version: .NET LINQ; verified on .NET 10.0.14

Syntax

source.Min(/* overload-specific arguments */)

Immediately enumerates and selects the smallest value or smallest selector result under the appropriate comparer.

Use it for a minimum when the overload matches the type and null rules.

For float and double, NaN affects the result according to the overload contract. Custom types need a consistent comparison.

An empty non-nullable source throws InvalidOperationException; nullable and reference behavior depends on the overload.

The complete program actually uses Enumerable.Min; its exact expected stdout is 3.

Examples

using System;
using System.Collections.Generic;
using System.Linq;

Console.WriteLine(new[] { 3, 9, 4 }.Min());

Result

3

The complete program actually uses `Enumerable.Min`; its exact expected stdout is `3`.

Sources