Enumerable.MaxBy メソッド

定義

オーバーロード

MaxBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

指定したキー セレクター関数に従って、ジェネリック シーケンスの最大値を返します。

MaxBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

指定したキー セレクター関数とキー比較子に従って、ジェネリック シーケンスの最大値を返します。

MaxBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

ソース:
Max.cs
ソース:
Max.cs
ソース:
Max.cs

指定したキー セレクター関数に従って、ジェネリック シーケンスの最大値を返します。

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

型パラメーター

TSource

source の要素の型。

TKey

要素を比較するキーの型。

パラメーター

source
IEnumerable<TSource>

最大値を確認する対象となる値のシーケンス。

keySelector
Func<TSource,TKey>

各要素のキーを抽出する関数。

戻り値

TSource

シーケンス内の最大キーを持つ値。

例外

sourcenull です。

からsource抽出されたキーは、 または IComparable<T> インターフェイスをIComparable実装しません。

TSource はプリミティブ型で、ソース シーケンスは空です。

注釈

ソース シーケンスが空で TSource 、null 許容型の場合、このメソッドは を返します null。 ソース シーケンスが空で TSource 、プリミティブ型などの null 非許容構造体である場合は、 InvalidOperationException がスローされます。

ソース シーケンスに である値のみが含まれている場合。null

適用対象

MaxBy<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IComparer<TKey>)

ソース:
Max.cs
ソース:
Max.cs
ソース:
Max.cs

指定したキー セレクター関数とキー比較子に従って、ジェネリック シーケンスの最大値を返します。

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static TSource MaxBy(System::Collections::Generic::IEnumerable<TSource> ^ source, Func<TSource, TKey> ^ keySelector, System::Collections::Generic::IComparer<TKey> ^ comparer);
public static TSource? MaxBy<TSource,TKey> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IComparer<TKey>? comparer);
static member MaxBy : seq<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IComparer<'Key> -> 'Source
<Extension()>
Public Function MaxBy(Of TSource, TKey) (source As IEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), comparer As IComparer(Of TKey)) As TSource

型パラメーター

TSource

source の要素の型。

TKey

要素を比較するキーの型。

パラメーター

source
IEnumerable<TSource>

最大値を確認する対象となる値のシーケンス。

keySelector
Func<TSource,TKey>

各要素のキーを抽出する関数。

comparer
IComparer<TKey>

IComparer<T>キーを比較する 。

戻り値

TSource

シーケンス内の最大キーを持つ値。

例外

sourcenull です。

からsource抽出されたキーは、 または IComparable<T> インターフェイスをIComparable実装しません。

TSource はプリミティブ型で、ソース シーケンスは空です。

注釈

ソース シーケンスが空で TSource 、null 許容型の場合、このメソッドは を返します null。 ソース シーケンスが空で TSource 、プリミティブ型などの null 非許容構造体である場合は、 InvalidOperationException がスローされます。

ソース シーケンスに である値のみが含まれている場合。null

適用対象