Enumerable.Min Metoda
Definicja
Zwraca wartość minimalną w sekwencji wartości.Returns the minimum value in a sequence of values.
Przeciążenia
Min(IEnumerable<Nullable<Int64>>) |
Zwraca wartość minimalną w sekwencji wartości dopuszczających wartość null Int64 .Returns the minimum value in a sequence of nullable Int64 values. |
Min(IEnumerable<Nullable<Int32>>) |
Zwraca wartość minimalną w sekwencji wartości dopuszczających wartość null Int32 .Returns the minimum value in a sequence of nullable Int32 values. |
Min(IEnumerable<Single>) |
Zwraca wartość minimalną w sekwencji Single wartości.Returns the minimum value in a sequence of Single values. |
Min(IEnumerable<Nullable<Single>>) |
Zwraca wartość minimalną w sekwencji wartości dopuszczających wartość null Single .Returns the minimum value in a sequence of nullable Single values. |
Min(IEnumerable<Nullable<Double>>) |
Zwraca wartość minimalną w sekwencji wartości dopuszczających wartość null Double .Returns the minimum value in a sequence of nullable Double values. |
Min(IEnumerable<Double>) |
Zwraca wartość minimalną w sekwencji Double wartości.Returns the minimum value in a sequence of Double values. |
Min(IEnumerable<Int64>) |
Zwraca wartość minimalną w sekwencji Int64 wartości.Returns the minimum value in a sequence of Int64 values. |
Min(IEnumerable<Int32>) |
Zwraca wartość minimalną w sekwencji Int32 wartości.Returns the minimum value in a sequence of Int32 values. |
Min(IEnumerable<Nullable<Decimal>>) |
Zwraca wartość minimalną w sekwencji wartości dopuszczających wartość null Decimal .Returns the minimum value in a sequence of nullable Decimal values. |
Min(IEnumerable<Decimal>) |
Zwraca wartość minimalną w sekwencji Decimal wartości.Returns the minimum value in a sequence of Decimal values. |
Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji ogólnej i zwraca minimalną wartość wynikową.Invokes a transform function on each element of a generic sequence and returns the minimum resulting value. |
Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca wartość minimalną 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>>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca minimalną Single wartość null.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>>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca minimalną Int64 wartość null.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>>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca minimalną Int32 wartość null.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>>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca minimalną Double wartość null.Invokes a transform function on each element of a sequence and returns the minimum nullable Double value. |
Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca wartość minimalną Int64 .Invokes a transform function on each element of a sequence and returns the minimum Int64 value. |
Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca wartość minimalną Int32 .Invokes a transform function on each element of a sequence and returns the minimum Int32 value. |
Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca wartość minimalną Double .Invokes a transform function on each element of a sequence and returns the minimum Double value. |
Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca wartość minimalną Decimal .Invokes a transform function on each element of a sequence and returns the minimum Decimal value. |
Min<TSource>(IEnumerable<TSource>) |
Zwraca wartość minimalną w sekwencji ogólnej.Returns the minimum value in a generic sequence. |
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) |
Wywołuje funkcję transformacji dla każdego elementu sekwencji i zwraca minimalną Decimal wartość null.Invokes a transform function on each element of a sequence and returns the minimum nullable Decimal value. |
Min(IEnumerable<Nullable<Int64>>)
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<long> Min(System::Collections::Generic::IEnumerable<Nullable<long>> ^ source);
public static 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)
Parametry
- source
- IEnumerable<Nullable<Int64>>
Sekwencja wartości null, Int64 Aby określić wartość minimalną.A sequence of nullable Int64 values to determine the minimum value of.
Zwraca
Wartość typu Nullable < Int64 >
w języku C# lub Nullable (Of Int64)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.A value of type Nullable<Int64>
in C# or Nullable(Of Int64)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
Uwagi
Min(IEnumerable<Nullable<Int64>>)Metoda używa Int64 implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Nullable<Int64>>) method uses the Int64 implementation of IComparable<T> to compare values.
Jeśli sekwencja źródłowa jest pusta lub zawiera tylko wartości, które są null
, ta funkcja zwraca wartość null
.If the source sequence is empty or contains only values that are null
, this function returns null
.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Nullable<Int32>>)
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<int> Min(System::Collections::Generic::IEnumerable<Nullable<int>> ^ source);
public static 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)
Parametry
- source
- IEnumerable<Nullable<Int32>>
Sekwencja wartości null, Int32 Aby określić wartość minimalną.A sequence of nullable Int32 values to determine the minimum value of.
Zwraca
Wartość typu < Int32 > null
w języku C# lub Nullable (z Int32)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.A value of type Nullable<Int32>
in C# or Nullable(Of Int32)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min(IEnumerable<Nullable<Int32>>) Aby określić minimalną wartość w sekwencji.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.
Console.WriteLine($"The lowest grade is {min}")
' This code produces the following output:
'
' The lowest grade is 37
Uwagi
Min(IEnumerable<Nullable<Int32>>)Metoda używa Int32 implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Nullable<Int32>>) method uses the Int32 implementation of IComparable<T> to compare values.
Jeśli sekwencja źródłowa jest pusta lub zawiera tylko wartości, które są null
, ta funkcja zwraca wartość null
.If the source sequence is empty or contains only values that are null
, this function returns null
.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Single>)
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
Parametry
- source
- IEnumerable<Single>
Sekwencja Single wartości do określenia wartości minimalnej.A sequence of Single values to determine the minimum value of.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Uwagi
Min(IEnumerable<Single>)Metoda używa Single implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Single>) method uses the Single implementation of IComparable<T> to compare values.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Nullable<Single>>)
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<float> Min(System::Collections::Generic::IEnumerable<Nullable<float>> ^ source);
public static 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)
Parametry
- source
- IEnumerable<Nullable<Single>>
Sekwencja wartości null, Single Aby określić wartość minimalną.A sequence of nullable Single values to determine the minimum value of.
Zwraca
Wartość typu null < Pojedyncza >
w języku C# lub Nullable (of Single)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.A value of type Nullable<Single>
in C# or Nullable(Of Single)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
Uwagi
Min(IEnumerable<Nullable<Single>>)Metoda używa Single implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Nullable<Single>>) method uses the Single implementation of IComparable<T> to compare values.
Jeśli sekwencja źródłowa jest pusta lub zawiera tylko wartości, które są null
, ta funkcja zwraca wartość null
.If the source sequence is empty or contains only values that are null
, this function returns null
.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Nullable<Double>>)
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<double> Min(System::Collections::Generic::IEnumerable<Nullable<double>> ^ source);
public static 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)
Parametry
- source
- IEnumerable<Nullable<Double>>
Sekwencja wartości null, Double Aby określić wartość minimalną.A sequence of nullable Double values to determine the minimum value of.
Zwraca
Wartość typu Nullable < Double >
w języku C# lub Nullable (of Double)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.A value of type Nullable<Double>
in C# or Nullable(Of Double)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
Uwagi
Min(IEnumerable<Nullable<Double>>)Metoda używa Double implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Nullable<Double>>) method uses the Double implementation of IComparable<T> to compare values.
Jeśli sekwencja źródłowa jest pusta lub zawiera tylko wartości, które są null
, ta funkcja zwraca wartość null
.If the source sequence is empty or contains only values that are null
, this function returns null
.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Double>)
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
Parametry
- source
- IEnumerable<Double>
Sekwencja Double wartości do określenia wartości minimalnej.A sequence of Double values to determine the minimum value of.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min(IEnumerable<Double>) Aby określić minimalną wartość w sekwencji.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.
Console.WriteLine($"The smallest number is {min}")
' This code produces the following output:
'
' The smallest number is -2E+103
Uwagi
Min(IEnumerable<Double>)Metoda używa Double implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Double>) method uses the Double implementation of IComparable<T> to compare values.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Int64>)
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
Parametry
- source
- IEnumerable<Int64>
Sekwencja Int64 wartości do określenia wartości minimalnej.A sequence of Int64 values to determine the minimum value of.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Uwagi
Min(IEnumerable<Int64>)Metoda używa Int64 implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Int64>) method uses the Int64 implementation of IComparable<T> to compare values.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Int32>)
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
Parametry
- source
- IEnumerable<Int32>
Sekwencja Int32 wartości do określenia wartości minimalnej.A sequence of Int32 values to determine the minimum value of.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Uwagi
Min(IEnumerable<Int32>)Metoda używa Int32 implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Int32>) method uses the Int32 implementation of IComparable<T> to compare values.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Nullable<Decimal>>)
public:
[System::Runtime::CompilerServices::Extension]
static Nullable<System::Decimal> Min(System::Collections::Generic::IEnumerable<Nullable<System::Decimal>> ^ source);
public static 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)
Parametry
- source
- IEnumerable<Nullable<Decimal>>
Sekwencja wartości null, Decimal Aby określić wartość minimalną.A sequence of nullable Decimal values to determine the minimum value of.
Zwraca
Wartość typu < Decimal > nullable
w języku C# lub Nullable (liczba dziesiętna)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.A value of type Nullable<Decimal>
in C# or Nullable(Of Decimal)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
Uwagi
Min(IEnumerable<Nullable<Decimal>>)Metoda używa Decimal implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Nullable<Decimal>>) method uses the Decimal implementation of IComparable<T> to compare values.
Jeśli sekwencja źródłowa jest pusta lub zawiera tylko wartości, które są null
, ta funkcja zwraca wartość null
.If the source sequence is empty or contains only values that are null
, this function returns null
.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min(IEnumerable<Decimal>)
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
Parametry
- source
- IEnumerable<Decimal>
Sekwencja Decimal wartości do określenia wartości minimalnej.A sequence of Decimal values to determine the minimum value of.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Uwagi
Min(IEnumerable<Decimal>)Metoda używa Decimal implementacji IComparable<T> do porównywania wartości.The Min(IEnumerable<Decimal>) method uses the Decimal implementation of IComparable<T> to compare values.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource,TResult>(IEnumerable<TSource>, Func<TSource,TResult>)
Wywołuje funkcję transformacji dla każdego elementu sekwencji ogólnej i zwraca minimalną wartość wynikową.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);
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
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
- TResult
Typ wartości zwracanej przez selector
.The type of the value returned by selector
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
- selector
- Func<TSource,TResult>
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
- TResult
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Jeśli typ TResult
implementuje IComparable<T> , ta metoda używa tej implementacji do porównywania wartości.If type TResult
implements IComparable<T>, this method uses that implementation to compare values. W przeciwnym razie, jeśli typ TResult
implementuje IComparable , ta implementacja jest używana do porównywania wartości.Otherwise, if type TResult
implements IComparable, that implementation is used to compare values.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>)
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
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>)Metoda używa Single implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Single>) method uses the Single implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która projektuje elementy członkowskie source
do typu liczbowego 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)
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 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)
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Wartość typu null < Pojedyncza >
w języku C# lub Nullable (of Single)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.The value of type Nullable<Single>
in C# or Nullable(Of Single)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>)Metoda używa Single implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Single>>) method uses the Single implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która zawiera projekty elementów członkowskich source
do typu liczbowego, w odniesieniu do Nullable<Single>
języka C# lub 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)
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 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)
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Wartość typu Nullable < Int64 >
w języku C# lub Nullable (Of Int64)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.The value of type Nullable<Int64>
in C# or Nullable(Of Int64)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>)Metoda używa Int64 implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int64>>) method uses the Int64 implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która zawiera projekty elementów członkowskich source
do typu liczbowego, w odniesieniu do Nullable<Int64>
języka C# lub 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)
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 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)
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Wartość typu null < >
w języku C# lub Nullable (z Int32)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.The value of type Nullable<Int32>
in C# or Nullable(Of Int32)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>)Metoda używa Int32 implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Int32>>) method uses the Int32 implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która zawiera projekty elementów członkowskich źródła do typu liczbowego, w tym Nullable<Int32>
w języku C# lub Nullable(Of Int32)
w 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)
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 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)
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Wartość typu Nullable < Double >
w języku C# lub Nullable (of Double)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.The value of type Nullable<Double>
in C# or Nullable(Of Double)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>)Metoda używa Double implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Double>>) method uses the Double implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która zawiera projekty elementów członkowskich source
do typu liczbowego, w odniesieniu do Nullable<Double>
języka C# lub 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)
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
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>)Metoda używa Int64 implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Int64>) method uses the Int64 implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która projektuje elementy członkowskie source
do typu liczbowego 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)
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
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>)Metoda używa Int32 implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) method uses the Int32 implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która projektuje elementy członkowskie source
do typu liczbowego 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>)
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
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>)Metoda używa Double implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Double>) method uses the Double implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która projektuje elementy członkowskie source
do typu liczbowego 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)
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
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
source
nie zawiera żadnych elementów.source
contains no elements.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>)Metoda używa Decimal implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Decimal>) method uses the Decimal implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która projektuje elementy członkowskie source
do typu liczbowego 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>)
Zwraca wartość minimalną w sekwencji ogólnej.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);
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
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Zwraca
- TSource
Minimalna wartość w sekwencji.The minimum value in the sequence.
Wyjątki
source
to null
.source
is null
.
Brak obiektu w source
implementującym IComparable IComparable<T> interfejsie lub.No object in source
implements the IComparable or IComparable<T> interface.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>) Aby określić minimalną wartość w sekwencji IComparable<T> obiektów.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.
Console.WriteLine($"The 'minimum' pet is {min.Name}")
End Sub
' This code produces the following output:
'
' The 'minimum' pet is Whiskers
Uwagi
Jeśli typ TSource
implementuje IComparable<T> , ta metoda używa tej implementacji do porównywania wartości.If type TSource
implements IComparable<T>, this method uses that implementation to compare values. W przeciwnym razie, jeśli typ TSource
implementuje IComparable , ta implementacja jest używana do porównywania wartości.Otherwise, if type TSource
implements IComparable, that implementation is used to compare values.
Jeśli TSource
jest typem referencyjnym, a sekwencja źródłowa jest pusta lub zawiera tylko wartości, które są null
, ta funkcja zwraca wartość null
.If TSource
is a reference type and the source sequence is empty or contains only values that are null
, this function returns null
.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.
Zobacz też
Dotyczy
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)
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 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)
Parametry typu
- TSource
Typ elementów source
.The type of the elements of source
.
Parametry
- source
- IEnumerable<TSource>
Kolejność wartości do określenia wartości minimalnej.A sequence of values to determine the minimum value of.
Funkcja transformacji do zastosowania do każdego elementu.A transform function to apply to each element.
Zwraca
Wartość typu < Decimal > nullable
w języku C# lub Nullable (liczba dziesiętna)
w Visual Basic, która odnosi się do wartości minimalnej w sekwencji.The value of type Nullable<Decimal>
in C# or Nullable(Of Decimal)
in Visual Basic that corresponds to the minimum value in the sequence.
Wyjątki
source
lub selector
jest null
.source
or selector
is null
.
Przykłady
Poniższy przykład kodu demonstruje, jak użyć, Min<TSource>(IEnumerable<TSource>, Func<TSource,Int32>) Aby określić minimalną wartość w sekwencji prognozowanych wartości.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.
Uwaga
W tym przykładzie kodu używane jest przeciążenie tej przeciążonej metody inne niż przeciążenie opisane w tym temacie.This code example uses an overload of this overloaded method that is different from the specific overload that this topic describes. W celu rozszerzenia tego przykładu tak, aby dotyczył tego tematu, należy zmienić treść funkcji 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.
Console.WriteLine($"The youngest pet is age {min}")
End Sub
' This code produces the following output:
'
' The youngest pet is age 1
Uwagi
Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>)Metoda używa Decimal implementacji IComparable<T> do porównywania wartości.The Min<TSource>(IEnumerable<TSource>, Func<TSource,Nullable<Decimal>>) method uses the Decimal implementation of IComparable<T> to compare values.
Tę metodę można zastosować do sekwencji dowolnych wartości, jeśli podajesz funkcję, selector
która zawiera projekty elementów członkowskich source
do typu liczbowego, w odniesieniu do Nullable<Decimal>
języka C# lub 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.
W Visual Basic składni wyrażenia zapytania, Aggregate Into Min()
klauzula tłumaczy na wywołanie Min .In Visual Basic query expression syntax, an Aggregate Into Min()
clause translates to an invocation of Min.