Click or drag to resize
EnumerableEx.MinBy<TSource, TKey> Method (IEnumerable<TSource>, Func<TSource, TKey>)
Returns the elements with the minimum key value by using the default comparer to compare key values.

Namespace: System.Linq
Assembly: System.Interactive (in System.Interactive.dll) Version: 1.2.0.0
Syntax
C#
public static IList<TSource> MinBy<TSource, TKey>(
	this IEnumerable<TSource> source,
	Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Collections.Generic.IEnumerable<TSource>
Source sequence.
keySelector
Type: System.Func<TSource, TKey>
Key selector used to extract the key for each element in the sequence.

Type Parameters

TSource
Source sequence element type.
TKey
Key type.

Return Value

Type: IList<TSource>
List with the elements that share the same minimum key value.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<TSource>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also