Enumerable.Min Enumerable.Min Enumerable.Min Enumerable.Min Method

定義

値のシーケンスの最小値を返します。Returns the minimum value in a sequence of values.

オーバーロード

Min(IEnumerable<Nullable<Int64>>) Min(IEnumerable<Nullable<Int64>>) Min(IEnumerable<Nullable<Int64>>) Min(IEnumerable<Nullable<Int64>>)

null 許容の Int64 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Int64 values.

Min(IEnumerable<Nullable<Int32>>) Min(IEnumerable<Nullable<Int32>>) Min(IEnumerable<Nullable<Int32>>) Min(IEnumerable<Nullable<Int32>>)

null 許容の Int32 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Int32 values.

Min(IEnumerable<Single>) Min(IEnumerable<Single>) Min(IEnumerable<Single>) Min(IEnumerable<Single>)

Single 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Single values.

Min(IEnumerable<Nullable<Single>>) Min(IEnumerable<Nullable<Single>>) Min(IEnumerable<Nullable<Single>>) Min(IEnumerable<Nullable<Single>>)

null 許容の Single 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Single values.

Min(IEnumerable<Nullable<Double>>) Min(IEnumerable<Nullable<Double>>) Min(IEnumerable<Nullable<Double>>) Min(IEnumerable<Nullable<Double>>)

null 許容の Double 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Double values.

Min(IEnumerable<Double>) Min(IEnumerable<Double>) Min(IEnumerable<Double>) Min(IEnumerable<Double>)

Double 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Double values.

Min(IEnumerable<Int64>) Min(IEnumerable<Int64>) Min(IEnumerable<Int64>) Min(IEnumerable<Int64>)

Int64 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Int64 values.

Min(IEnumerable<Int32>) Min(IEnumerable<Int32>) Min(IEnumerable<Int32>) Min(IEnumerable<Int32>)

Int32 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Int32 values.

Min(IEnumerable<Nullable<Decimal>>) Min(IEnumerable<Nullable<Decimal>>) Min(IEnumerable<Nullable<Decimal>>) Min(IEnumerable<Nullable<Decimal>>)

null 許容の Decimal 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Decimal values.

Min(IEnumerable<Decimal>) Min(IEnumerable<Decimal>) Min(IEnumerable<Decimal>) Min(IEnumerable<Decimal>)

Decimal 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Decimal values.

Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>) Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>) Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>) Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

ジェネリック シーケンスの各要素に対して変換関数を呼び出し、結果の最小値を返します。Invokes a transform function on each element of a generic sequence and returns the minimum resulting value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

シーケンスの各要素に対して変換関数を呼び出し、Single の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Single value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Single の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Single value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Int64 の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Int64 value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Int32 の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Int32 value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Double の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Double value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

シーケンスの各要素に対して変換関数を呼び出し、Int64 の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Int64 value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

シーケンスの各要素に対して変換関数を呼び出し、Int32 の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Int32 value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

シーケンスの各要素に対して変換関数を呼び出し、Double の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Double value.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

シーケンスの各要素に対して変換関数を呼び出し、Decimal の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Decimal value.

Min<TSource>(IEnumerable<TSource>) Min<TSource>(IEnumerable<TSource>) Min<TSource>(IEnumerable<TSource>) Min<TSource>(IEnumerable<TSource>)

ジェネリック シーケンスの最小値を返します。Returns the minimum value in a generic sequence.

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Decimal の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Decimal value.

Min(IEnumerable<Nullable<Int64>>) Min(IEnumerable<Nullable<Int64>>) Min(IEnumerable<Nullable<Int64>>) Min(IEnumerable<Nullable<Int64>>)

null 許容の Int64 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Int64 values.

public:
[System::Runtime::CompilerServices::Extension]
 static Nullable<long> Min(System::Collections::Generic::IEnumerable<Nullable<long>> ^ source);
public static Nullable<long> Min (this System.Collections.Generic.IEnumerable<Nullable<long>> source);
static member Min : seq<Nullable<int64>> -> Nullable<int64>
<Extension()>
Public Function Min (source As IEnumerable(Of Nullable(Of Long))) As Nullable(Of Long)

パラメーター

source
IEnumerable<Nullable<Int64>>

最小値を確認する対象となる null 許容の Int64 値のシーケンス。A sequence of nullable Int64 values to determine the minimum value of.

戻り値

シーケンスの最小値に対応する Nullable<Int64> 型 (C# の場合) または Nullable(Of Int64) 型 (Visual Basic の場合) の値。A value of type Nullable<Int64> in C# or Nullable(Of Int64) in Visual Basic that corresponds to the minimum value in the sequence.

例外

次のコード例は、使用する方法を示しますMin(IEnumerable<Nullable<Int32>>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Nullable<Int32>>) to determine the minimum value in a sequence.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、ソース シーケンスの要素を適切な数値型の要素に置き換えます。To extend the example to this topic, substitute the elements of the source sequence with elements of the appropriate numerical type.

int?[] grades = { 78, 92, null, 99, 37, 81 };

int? min = grades.Min();

Console.WriteLine("The lowest grade is {0}.", min);

/*
 This code produces the following output:

 The lowest grade is 37.
*/
Dim grades() As Nullable(Of Integer) = {78, 92, Nothing, 99, 37, 81}
Dim min As Nullable(Of Integer) = grades.Min()

' Display the output.
MsgBox("The lowest grade is " & min)

' This code produces the following output:
'
' The lowest grade is 37

注釈

Min(IEnumerable<Nullable<Int64>>)メソッドは、Int64の実装IComparable<T>値を比較します。The Min(IEnumerable<Nullable<Int64>>) method uses the Int64 implementation of IComparable<T> to compare values.

ソース シーケンスが空かは値のみを含むかどうかnull、この関数を返しますnullします。If the source sequence is empty or contains only values that are null, this function returns null.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Nullable<Int32>>) Min(IEnumerable<Nullable<Int32>>) Min(IEnumerable<Nullable<Int32>>) Min(IEnumerable<Nullable<Int32>>)

null 許容の Int32 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Int32 values.

public:
[System::Runtime::CompilerServices::Extension]
 static Nullable<int> Min(System::Collections::Generic::IEnumerable<Nullable<int>> ^ source);
public static Nullable<int> Min (this System.Collections.Generic.IEnumerable<Nullable<int>> source);
static member Min : seq<Nullable<int>> -> Nullable<int>
<Extension()>
Public Function Min (source As IEnumerable(Of Nullable(Of Integer))) As Nullable(Of Integer)

パラメーター

source
IEnumerable<Nullable<Int32>>

最小値を確認する対象となる null 許容の Int32 値のシーケンス。A sequence of nullable Int32 values to determine the minimum value of.

戻り値

シーケンスの最小値に対応する Nullable<Int32> 型 (C# の場合) または Nullable(Of Int32) 型 (Visual Basic の場合) の値。A value of type Nullable<Int32> in C# or Nullable(Of Int32) in Visual Basic that corresponds to the minimum value in the sequence.

例外

次のコード例は、使用する方法を示しますMin(IEnumerable<Nullable<Int32>>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Nullable<Int32>>) to determine the minimum value in a sequence.

int?[] grades = { 78, 92, null, 99, 37, 81 };

int? min = grades.Min();

Console.WriteLine("The lowest grade is {0}.", min);

/*
 This code produces the following output:

 The lowest grade is 37.
*/
Dim grades() As Nullable(Of Integer) = {78, 92, Nothing, 99, 37, 81}
Dim min As Nullable(Of Integer) = grades.Min()

' Display the output.
MsgBox("The lowest grade is " & min)

' This code produces the following output:
'
' The lowest grade is 37

注釈

Min(IEnumerable<Nullable<Int32>>)メソッドは、Int32の実装IComparable<T>値を比較します。The Min(IEnumerable<Nullable<Int32>>) method uses the Int32 implementation of IComparable<T> to compare values.

ソース シーケンスが空かは値のみを含むかどうかnull、この関数を返しますnullします。If the source sequence is empty or contains only values that are null, this function returns null.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Single>) Min(IEnumerable<Single>) Min(IEnumerable<Single>) Min(IEnumerable<Single>)

Single 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Single values.

public:
[System::Runtime::CompilerServices::Extension]
 static float Min(System::Collections::Generic::IEnumerable<float> ^ source);
public static float Min (this System.Collections.Generic.IEnumerable<float> source);
static member Min : seq<single> -> single
<Extension()>
Public Function Min (source As IEnumerable(Of Single)) As Single

パラメーター

source
IEnumerable<Single>

最小値を確認する対象となる Single 値のシーケンス。A sequence of Single values to determine the minimum value of.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin(IEnumerable<Double>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Double>) to determine the minimum value in a sequence.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、ソース シーケンスの要素を適切な数値型の要素に置き換えます。To extend the example to this topic, substitute the elements of the source sequence with elements of the appropriate numerical type.

double[] doubles = { 1.5E+104, 9E+103, -2E+103 };

double min = doubles.Min();

Console.WriteLine("The smallest number is {0}.", min);

/*
 This code produces the following output:

 The smallest number is -2E+103.
*/
' Create an array of double values.
Dim doubles() As Double = {1.5E+104, 9.0E+103, -2.0E+103}

' Determine the smallest number in the array.
Dim min As Double = doubles.Min()

' Display the result.
MsgBox("The smallest number is " & min)

' This code produces the following output:
'
' The smallest number is -2E+103

注釈

Min(IEnumerable<Single>)メソッドは、Singleの実装IComparable<T>値を比較します。The Min(IEnumerable<Single>) method uses the Single implementation of IComparable<T> to compare values.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Nullable<Single>>) Min(IEnumerable<Nullable<Single>>) Min(IEnumerable<Nullable<Single>>) Min(IEnumerable<Nullable<Single>>)

null 許容の Single 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Single values.

public:
[System::Runtime::CompilerServices::Extension]
 static Nullable<float> Min(System::Collections::Generic::IEnumerable<Nullable<float>> ^ source);
public static Nullable<float> Min (this System.Collections.Generic.IEnumerable<Nullable<float>> source);
static member Min : seq<Nullable<single>> -> Nullable<single>
<Extension()>
Public Function Min (source As IEnumerable(Of Nullable(Of Single))) As Nullable(Of Single)

パラメーター

source
IEnumerable<Nullable<Single>>

最小値を確認する対象となる null 許容の Single 値のシーケンス。A sequence of nullable Single values to determine the minimum value of.

戻り値

シーケンスの最小値に対応する Nullable<Single> 型 (C# の場合) または Nullable(Of Single) 型 (Visual Basic の場合) の値。A value of type Nullable<Single> in C# or Nullable(Of Single) in Visual Basic that corresponds to the minimum value in the sequence.

例外

次のコード例は、使用する方法を示しますMin(IEnumerable<Nullable<Int32>>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Nullable<Int32>>) to determine the minimum value in a sequence.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、ソース シーケンスの要素を適切な数値型の要素に置き換えます。To extend the example to this topic, substitute the elements of the source sequence with elements of the appropriate numerical type.

int?[] grades = { 78, 92, null, 99, 37, 81 };

int? min = grades.Min();

Console.WriteLine("The lowest grade is {0}.", min);

/*
 This code produces the following output:

 The lowest grade is 37.
*/
Dim grades() As Nullable(Of Integer) = {78, 92, Nothing, 99, 37, 81}
Dim min As Nullable(Of Integer) = grades.Min()

' Display the output.
MsgBox("The lowest grade is " & min)

' This code produces the following output:
'
' The lowest grade is 37

注釈

Min(IEnumerable<Nullable<Single>>)メソッドは、Singleの実装IComparable<T>値を比較します。The Min(IEnumerable<Nullable<Single>>) method uses the Single implementation of IComparable<T> to compare values.

ソース シーケンスが空かは値のみを含むかどうかnull、この関数を返しますnullします。If the source sequence is empty or contains only values that are null, this function returns null.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Nullable<Double>>) Min(IEnumerable<Nullable<Double>>) Min(IEnumerable<Nullable<Double>>) Min(IEnumerable<Nullable<Double>>)

null 許容の Double 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Double values.

public:
[System::Runtime::CompilerServices::Extension]
 static Nullable<double> Min(System::Collections::Generic::IEnumerable<Nullable<double>> ^ source);
public static Nullable<double> Min (this System.Collections.Generic.IEnumerable<Nullable<double>> source);
static member Min : seq<Nullable<double>> -> Nullable<double>
<Extension()>
Public Function Min (source As IEnumerable(Of Nullable(Of Double))) As Nullable(Of Double)

パラメーター

source
IEnumerable<Nullable<Double>>

最小値を確認する対象となる null 許容の Double 値のシーケンス。A sequence of nullable Double values to determine the minimum value of.

戻り値

シーケンスの最小値に対応する Nullable<Double> 型 (C# の場合) または Nullable(Of Double) 型 (Visual Basic の場合) の値。A value of type Nullable<Double> in C# or Nullable(Of Double) in Visual Basic that corresponds to the minimum value in the sequence.

例外

次のコード例は、使用する方法を示しますMin(IEnumerable<Nullable<Int32>>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Nullable<Int32>>) to determine the minimum value in a sequence.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、ソース シーケンスの要素を適切な数値型の要素に置き換えます。To extend the example to this topic, substitute the elements of the source sequence with elements of the appropriate numerical type.

int?[] grades = { 78, 92, null, 99, 37, 81 };

int? min = grades.Min();

Console.WriteLine("The lowest grade is {0}.", min);

/*
 This code produces the following output:

 The lowest grade is 37.
*/
Dim grades() As Nullable(Of Integer) = {78, 92, Nothing, 99, 37, 81}
Dim min As Nullable(Of Integer) = grades.Min()

' Display the output.
MsgBox("The lowest grade is " & min)

' This code produces the following output:
'
' The lowest grade is 37

注釈

Min(IEnumerable<Nullable<Double>>)メソッドは、Doubleの実装IComparable<T>値を比較します。The Min(IEnumerable<Nullable<Double>>) method uses the Double implementation of IComparable<T> to compare values.

ソース シーケンスが空かは値のみを含むかどうかnull、この関数を返しますnullします。If the source sequence is empty or contains only values that are null, this function returns null.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Double>) Min(IEnumerable<Double>) Min(IEnumerable<Double>) Min(IEnumerable<Double>)

Double 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Double values.

public:
[System::Runtime::CompilerServices::Extension]
 static double Min(System::Collections::Generic::IEnumerable<double> ^ source);
public static double Min (this System.Collections.Generic.IEnumerable<double> source);
static member Min : seq<double> -> double
<Extension()>
Public Function Min (source As IEnumerable(Of Double)) As Double

パラメーター

source
IEnumerable<Double>

最小値を確認する対象となる Double 値のシーケンス。A sequence of Double values to determine the minimum value of.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin(IEnumerable<Double>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Double>) to determine the minimum value in a sequence.

double[] doubles = { 1.5E+104, 9E+103, -2E+103 };

double min = doubles.Min();

Console.WriteLine("The smallest number is {0}.", min);

/*
 This code produces the following output:

 The smallest number is -2E+103.
*/
' Create an array of double values.
Dim doubles() As Double = {1.5E+104, 9.0E+103, -2.0E+103}

' Determine the smallest number in the array.
Dim min As Double = doubles.Min()

' Display the result.
MsgBox("The smallest number is " & min)

' This code produces the following output:
'
' The smallest number is -2E+103

注釈

Min(IEnumerable<Double>)メソッドは、Doubleの実装IComparable<T>値を比較します。The Min(IEnumerable<Double>) method uses the Double implementation of IComparable<T> to compare values.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Int64>) Min(IEnumerable<Int64>) Min(IEnumerable<Int64>) Min(IEnumerable<Int64>)

Int64 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Int64 values.

public:
[System::Runtime::CompilerServices::Extension]
 static long Min(System::Collections::Generic::IEnumerable<long> ^ source);
public static long Min (this System.Collections.Generic.IEnumerable<long> source);
static member Min : seq<int64> -> int64
<Extension()>
Public Function Min (source As IEnumerable(Of Long)) As Long

パラメーター

source
IEnumerable<Int64>

最小値を確認する対象となる Int64 値のシーケンス。A sequence of Int64 values to determine the minimum value of.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin(IEnumerable<Double>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Double>) to determine the minimum value in a sequence.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、ソース シーケンスの要素を適切な数値型の要素に置き換えます。To extend the example to this topic, substitute the elements of the source sequence with elements of the appropriate numerical type.

double[] doubles = { 1.5E+104, 9E+103, -2E+103 };

double min = doubles.Min();

Console.WriteLine("The smallest number is {0}.", min);

/*
 This code produces the following output:

 The smallest number is -2E+103.
*/
' Create an array of double values.
Dim doubles() As Double = {1.5E+104, 9.0E+103, -2.0E+103}

' Determine the smallest number in the array.
Dim min As Double = doubles.Min()

' Display the result.
MsgBox("The smallest number is " & min)

' This code produces the following output:
'
' The smallest number is -2E+103

注釈

Min(IEnumerable<Int64>)メソッドは、Int64の実装IComparable<T>値を比較します。The Min(IEnumerable<Int64>) method uses the Int64 implementation of IComparable<T> to compare values.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Int32>) Min(IEnumerable<Int32>) Min(IEnumerable<Int32>) Min(IEnumerable<Int32>)

Int32 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Int32 values.

public:
[System::Runtime::CompilerServices::Extension]
 static int Min(System::Collections::Generic::IEnumerable<int> ^ source);
public static int Min (this System.Collections.Generic.IEnumerable<int> source);
static member Min : seq<int> -> int
<Extension()>
Public Function Min (source As IEnumerable(Of Integer)) As Integer

パラメーター

source
IEnumerable<Int32>

最小値を確認する対象となる Int32 値のシーケンス。A sequence of Int32 values to determine the minimum value of.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin(IEnumerable<Double>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Double>) to determine the minimum value in a sequence.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、ソース シーケンスの要素を適切な数値型の要素に置き換えます。To extend the example to this topic, substitute the elements of the source sequence with elements of the appropriate numerical type.

double[] doubles = { 1.5E+104, 9E+103, -2E+103 };

double min = doubles.Min();

Console.WriteLine("The smallest number is {0}.", min);

/*
 This code produces the following output:

 The smallest number is -2E+103.
*/
' Create an array of double values.
Dim doubles() As Double = {1.5E+104, 9.0E+103, -2.0E+103}

' Determine the smallest number in the array.
Dim min As Double = doubles.Min()

' Display the result.
MsgBox("The smallest number is " & min)

' This code produces the following output:
'
' The smallest number is -2E+103

注釈

Min(IEnumerable<Int32>)メソッドは、Int32の実装IComparable<T>値を比較します。The Min(IEnumerable<Int32>) method uses the Int32 implementation of IComparable<T> to compare values.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Nullable<Decimal>>) Min(IEnumerable<Nullable<Decimal>>) Min(IEnumerable<Nullable<Decimal>>) Min(IEnumerable<Nullable<Decimal>>)

null 許容の Decimal 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of nullable Decimal values.

public:
[System::Runtime::CompilerServices::Extension]
 static Nullable<System::Decimal> Min(System::Collections::Generic::IEnumerable<Nullable<System::Decimal>> ^ source);
public static Nullable<decimal> Min (this System.Collections.Generic.IEnumerable<Nullable<decimal>> source);
static member Min : seq<Nullable<decimal>> -> Nullable<decimal>
<Extension()>
Public Function Min (source As IEnumerable(Of Nullable(Of Decimal))) As Nullable(Of Decimal)

パラメーター

source
IEnumerable<Nullable<Decimal>>

最小値を確認する対象となる null 許容の Decimal 値のシーケンス。A sequence of nullable Decimal values to determine the minimum value of.

戻り値

シーケンスの最小値に対応する Nullable<Decimal> 型 (C# の場合) または Nullable(Of Decimal) 型 (Visual Basic の場合) の値。A value of type Nullable<Decimal> in C# or Nullable(Of Decimal) in Visual Basic that corresponds to the minimum value in the sequence.

例外

次のコード例は、使用する方法を示しますMin(IEnumerable<Nullable<Int32>>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Nullable<Int32>>) to determine the minimum value in a sequence.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、ソース シーケンスの要素を適切な数値型の要素に置き換えます。To extend the example to this topic, substitute the elements of the source sequence with elements of the appropriate numerical type.

int?[] grades = { 78, 92, null, 99, 37, 81 };

int? min = grades.Min();

Console.WriteLine("The lowest grade is {0}.", min);

/*
 This code produces the following output:

 The lowest grade is 37.
*/
Dim grades() As Nullable(Of Integer) = {78, 92, Nothing, 99, 37, 81}
Dim min As Nullable(Of Integer) = grades.Min()

' Display the output.
MsgBox("The lowest grade is " & min)

' This code produces the following output:
'
' The lowest grade is 37

注釈

Min(IEnumerable<Nullable<Decimal>>)メソッドは、Decimalの実装IComparable<T>値を比較します。The Min(IEnumerable<Nullable<Decimal>>) method uses the Decimal implementation of IComparable<T> to compare values.

ソース シーケンスが空かは値のみを含むかどうかnull、この関数を返しますnullします。If the source sequence is empty or contains only values that are null, this function returns null.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min(IEnumerable<Decimal>) Min(IEnumerable<Decimal>) Min(IEnumerable<Decimal>) Min(IEnumerable<Decimal>)

Decimal 値のシーケンスの最小値を返します。Returns the minimum value in a sequence of Decimal values.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Decimal Min(System::Collections::Generic::IEnumerable<System::Decimal> ^ source);
public static decimal Min (this System.Collections.Generic.IEnumerable<decimal> source);
static member Min : seq<decimal> -> decimal
<Extension()>
Public Function Min (source As IEnumerable(Of Decimal)) As Decimal

パラメーター

source
IEnumerable<Decimal>

最小値を確認する対象となる Decimal 値のシーケンス。A sequence of Decimal values to determine the minimum value of.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin(IEnumerable<Double>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min(IEnumerable<Double>) to determine the minimum value in a sequence.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、ソース シーケンスの要素を適切な数値型の要素に置き換えます。To extend the example to this topic, substitute the elements of the source sequence with elements of the appropriate numerical type.

double[] doubles = { 1.5E+104, 9E+103, -2E+103 };

double min = doubles.Min();

Console.WriteLine("The smallest number is {0}.", min);

/*
 This code produces the following output:

 The smallest number is -2E+103.
*/
' Create an array of double values.
Dim doubles() As Double = {1.5E+104, 9.0E+103, -2.0E+103}

' Determine the smallest number in the array.
Dim min As Double = doubles.Min()

' Display the result.
MsgBox("The smallest number is " & min)

' This code produces the following output:
'
' The smallest number is -2E+103

注釈

Min(IEnumerable<Decimal>)メソッドは、Decimalの実装IComparable<T>値を比較します。The Min(IEnumerable<Decimal>) method uses the Decimal implementation of IComparable<T> to compare values.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>) Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>) Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>) Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)

ジェネリック シーケンスの各要素に対して変換関数を呼び出し、結果の最小値を返します。Invokes a transform function on each element of a generic sequence and returns the minimum resulting value.

public:
generic <typename TSource, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static TResult Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, TResult> ^ selector);
public static TResult Min<TSource,TResult> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TResult> selector);
static member Min : seq<'Source> * Func<'Source, 'Result> -> 'Result
<Extension()>
Public Function Min(Of TSource, TResult) (source As IEnumerable(Of TSource), selector As Func(Of TSource, TResult)) As TResult

型パラメーター

TSource

source の要素の型。The type of the elements of source.

TResult

selector によって返される値の型。The type of the value returned by selector.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,TResult>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

TResult TResult TResult TResult

シーケンスの最小値。The minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

場合型TResult実装IComparable<T>、このメソッドでは、その実装を使用して、値を比較します。If type TResult implements IComparable<T>, this method uses that implementation to compare values. 場合は、型TResult実装IComparable、その実装を使用して値を比較します。Otherwise, if type TResult implements IComparable, that implementation is used to compare values.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>)

シーケンスの各要素に対して変換関数を呼び出し、Single の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Single value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static float Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, float> ^ selector);
public static float Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,float> selector);
static member Min : seq<'Source> * Func<'Source, single> -> single
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Single)) As Single

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Single>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>)メソッドは、Singleの実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) method uses the Single implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceを数値の型に特にSingleします。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Single.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Single の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Single value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static Nullable<float> Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<float>> ^ selector);
public static Nullable<float> Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,Nullable<float>> selector);
static member Min : seq<'Source> * Func<'Source, Nullable<single>> -> Nullable<single>
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Single))) As Nullable(Of Single)

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Nullable<Single>>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値に対応する Nullable<Single> 型 (C# の場合) または Nullable(Of Single) 型 (Visual Basic の場合) の値。The value of type Nullable<Single> in C# or Nullable(Of Single) in Visual Basic that corresponds to the minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)メソッドは、Singleの実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) method uses the Single implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceに数値型では、具体的にはNullable<Single>(C#) またはNullable(Of Single)Visual Basic でします。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Nullable<Single> in C# or Nullable(Of Single) in Visual Basic.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Int64 の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Int64 value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static Nullable<long> Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<long>> ^ selector);
public static Nullable<long> Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,Nullable<long>> selector);
static member Min : seq<'Source> * Func<'Source, Nullable<int64>> -> Nullable<int64>
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Long))) As Nullable(Of Long)

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Nullable<Int64>>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値に対応する Nullable<Int64> 型 (C# の場合) または Nullable(Of Int64) 型 (Visual Basic の場合) の値。The value of type Nullable<Int64> in C# or Nullable(Of Int64) in Visual Basic that corresponds to the minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)メソッドは、Int64の実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) method uses the Int64 implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceに数値型では、具体的にはNullable<Int64>(C#) またはNullable(Of Int64)Visual Basic でします。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Nullable<Int64> in C# or Nullable(Of Int64) in Visual Basic.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Int32 の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Int32 value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static Nullable<int> Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<int>> ^ selector);
public static Nullable<int> Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,Nullable<int>> selector);
static member Min : seq<'Source> * Func<'Source, Nullable<int>> -> Nullable<int>
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Integer))) As Nullable(Of Integer)

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Nullable<Int32>>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値に対応する Nullable<Int32> 型 (C# の場合) または Nullable(Of Int32) 型 (Visual Basic の場合) の値。The value of type Nullable<Int32> in C# or Nullable(Of Int32) in Visual Basic that corresponds to the minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)メソッドは、Int32の実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) method uses the Int32 implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselector、具体的には、数値型にソースのメンバーを射影するNullable<Int32>(C#) またはNullable(Of Int32)Visual Basic でします。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Nullable<Int32> in C# or Nullable(Of Int32) in Visual Basic.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Double の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Double value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static Nullable<double> Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<double>> ^ selector);
public static Nullable<double> Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,Nullable<double>> selector);
static member Min : seq<'Source> * Func<'Source, Nullable<double>> -> Nullable<double>
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Double))) As Nullable(Of Double)

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Nullable<Double>>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値に対応する Nullable<Double> 型 (C# の場合) または Nullable(Of Double) 型 (Visual Basic の場合) の値。The value of type Nullable<Double> in C# or Nullable(Of Double) in Visual Basic that corresponds to the minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)メソッドは、Doubleの実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) method uses the Double implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceに数値型では、具体的にはNullable<Double>(C#) またはNullable(Of Double)Visual Basic でします。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Nullable<Double> in C# or Nullable(Of Double) in Visual Basic.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)

シーケンスの各要素に対して変換関数を呼び出し、Int64 の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Int64 value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static long Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, long> ^ selector);
public static long Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,long> selector);
static member Min : seq<'Source> * Func<'Source, int64> -> int64
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Long)) As Long

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Int64>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)メソッドは、Int64の実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) method uses the Int64 implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceを数値の型に特にInt64します。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Int64.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)

シーケンスの各要素に対して変換関数を呼び出し、Int32 の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Int32 value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static int Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, int> ^ selector);
public static int Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,int> selector);
static member Min : seq<'Source> * Func<'Source, int> -> int
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Integer)) As Integer

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Int32>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)メソッドは、Int32の実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) method uses the Int32 implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceを数値の型に特にInt32します。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Int32.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>)

シーケンスの各要素に対して変換関数を呼び出し、Double の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Double value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static double Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, double> ^ selector);
public static double Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,double> selector);
static member Min : seq<'Source> * Func<'Source, double> -> double
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Double)) As Double

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Double>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>)メソッドは、Doubleの実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) method uses the Double implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceを数値の型に特にDoubleします。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Double.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)

シーケンスの各要素に対して変換関数を呼び出し、Decimal の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum Decimal value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Decimal Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, System::Decimal> ^ selector);
public static decimal Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,decimal> selector);
static member Min : seq<'Source> * Func<'Source, decimal> -> decimal
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Decimal)) As Decimal

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Decimal>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値。The minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

source に要素が含まれていません。source contains no elements.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)メソッドは、Decimalの実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) method uses the Decimal implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceを数値の型に特にDecimalします。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Decimal.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>) Min<TSource>(IEnumerable<TSource>) Min<TSource>(IEnumerable<TSource>) Min<TSource>(IEnumerable<TSource>)

ジェネリック シーケンスの最小値を返します。Returns the minimum value in a generic sequence.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static TSource Min(System::Collections::Generic::IEnumerable<TSource> ^ source);
public static TSource Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source);
static member Min : seq<'Source> -> 'Source
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource)) As TSource

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

戻り値

TSource TSource TSource TSource

シーケンスの最小値。The minimum value in the sequence.

例外

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>)のシーケンスの最小値を決定するIComparable<T>オブジェクト。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>) to determine the minimum value in a sequence of IComparable<T> objects.

/// <summary>
/// This class implements IComparable in order to 
/// be able to compare different Pet objects.
/// </summary>
class Pet : IComparable<Pet>
{
    public string Name { get; set; }
    public int Age { get; set; }

    /// <summary>
    /// Compares this Pet's age to another Pet's age.
    /// </summary>
    /// <param name="other">The Pet to compare this Pet to.</param>
    /// <returns>-1 if this Pet's age is smaller, 
    /// 0 if the Pets' ages are equal, or 
    /// 1 if this Pet's age is greater.</returns>
    int IComparable<Pet>.CompareTo(Pet other)
    {
        if (other.Age > this.Age)
            return -1;
        else if (other.Age == this.Age)
            return 0;
        else
            return 1;
    }
}

public static void MinEx3()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    Pet min = pets.Min();

    Console.WriteLine(
        "The 'minimum' animal is {0}.",
        min.Name);
}

/*
 This code produces the following output:

 The 'minimum' animal is Whiskers.
*/
' This class implements IComparable 
' and has a custom 'CompareTo' implementation.
Class Pet
    Implements IComparable(Of Pet)

    Public Name As String
    Public Age As Integer

    ''' <summary>
    ''' Compares this Pet's age to another Pet's age.
    ''' </summary>
    ''' <param name="other">The Pet to compare this Pet to.</param>
    ''' <returns>-1 if this Pet's age is smaller,
    ''' 0 if the Pets' ages are equal,
    ''' or 1 if this Pet's age is greater.</returns>
    Function CompareTo(ByVal other As Pet) As Integer _
    Implements IComparable(Of Pet).CompareTo

        If (other.Age > Me.Age) Then
            Return -1
        ElseIf (other.Age = Me.Age) Then
            Return 0
        Else
            Return 1
        End If
    End Function
End Class

Sub MinEx3()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Determine the "minimum" pet in the array,
    ' according to the custom CompareTo() implementation.
    Dim min As Pet = pets.Min()

    ' Display the result.
    MsgBox("The 'minimum' pet is " & min.Name)
End Sub

' This code produces the following output:
'
' The 'minimum' pet is Whiskers

注釈

場合型TSource実装IComparable<T>、このメソッドでは、その実装を使用して、値を比較します。If type TSource implements IComparable<T>, this method uses that implementation to compare values. 場合は、型TSource実装IComparable、その実装を使用して値を比較します。Otherwise, if type TSource implements IComparable, that implementation is used to compare values.

場合TSourceは参照型であり、ソース シーケンスが空であるかは値のみが含まれますnull、この関数を返しますnullします。If TSource is a reference type and the source sequence is empty or contains only values that are null, this function returns null.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)

シーケンスの各要素に対して変換関数を呼び出し、null 許容の Decimal の最小値を返します。Invokes a transform function on each element of a sequence and returns the minimum nullable Decimal value.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static Nullable<System::Decimal> Min(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, Nullable<System::Decimal>> ^ selector);
public static Nullable<decimal> Min<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,Nullable<decimal>> selector);
static member Min : seq<'Source> * Func<'Source, Nullable<decimal>> -> Nullable<decimal>
<Extension()>
Public Function Min(Of TSource) (source As IEnumerable(Of TSource), selector As Func(Of TSource, Nullable(Of Decimal))) As Nullable(Of Decimal)

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IEnumerable<TSource>

最小値を確認する対象となる値のシーケンス。A sequence of values to determine the minimum value of.

selector
Func<TSource,Nullable<Decimal>>

各要素に適用する変換関数。A transform function to apply to each element.

戻り値

シーケンスの最小値に対応する Nullable<Decimal> 型 (C# の場合) または Nullable(Of Decimal) 型 (Visual Basic の場合) の値。The value of type Nullable<Decimal> in C# or Nullable(Of Decimal) in Visual Basic that corresponds to the minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

次のコード例は、使用する方法を示しますMin<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) to determine the minimum value in a sequence of projected values.

注意

このコード例で使用するオーバーロードされたメソッドのオーバーロードは、このトピックで説明する特定のオーバーロードとは異なります。This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. コード例をこのトピックに適用するには、selector 関数の本体を変更します。To extend the example to this topic, change the body of the selector function.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx4()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    int min = pets.Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
 This code produces the following output:

 The youngest animal is age 1.  
*/
Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Sub MinEx4()
    ' Create an array of Pet objects.
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8},
                     New Pet With {.Name = "Boots", .Age = 4},
                     New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Find the youngest pet by passing a 
    ' lambda expression to the Min() method.
    Dim min As Integer = pets.Min(Function(pet) pet.Age)

    ' Display the result.
    MsgBox("The youngest pet is age " & min)
End Sub

' This code produces the following output:
'
' The youngest pet is age 1

注釈

Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)メソッドは、Decimalの実装IComparable<T>値を比較します。The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) method uses the Decimal implementation of IComparable<T> to compare values.

関数を提供する場合、このメソッドを任意の値のシーケンスに適用することができますselectorのメンバーを射影するsourceに数値型では、具体的にはNullable<Decimal>(C#) またはNullable(Of Decimal)Visual Basic でします。You can apply this method to a sequence of arbitrary values if you provide a function, selector, that projects the members of source into a numeric type, specifically Nullable<Decimal> in C# or Nullable(Of Decimal) in Visual Basic.

Visual Basic のクエリ式の構文、Aggregate Into Min()の呼び出しに変換句Minします。In Visual Basic query expression syntax, an Aggregate Into Min() clause translates to an invocation of Min.

こちらもご覧ください

適用対象