Skip to content

M_CodeJam_Collections_EnumerableExtensions_MaxBy__2_1

andrewvk edited this page Apr 13, 2016 · 5 revisions

EnumerableExtensions.MaxBy(TSource, TValue) Method (IEnumerable(TSource), Func(TSource, TValue), IComparer(TValue))

[This is preliminary documentation and is subject to change.]

Invokes a selector on each element of a source and returns the item with maximum value.

Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#

public static TSource MaxBy<TSource, TValue>(
	this IEnumerable<TSource> source,
	Func<TSource, TValue> selector,
	IComparer<TValue> comparer
)

VB

<ExtensionAttribute>
Public Shared Function MaxBy(Of TSource, TValue) ( 
	source As IEnumerable(Of TSource),
	selector As Func(Of TSource, TValue),
	comparer As IComparer(Of TValue)
) As TSource

F#

[<ExtensionAttribute>]
static member MaxBy : 
        source : IEnumerable<'TSource> * 
        selector : Func<'TSource, 'TValue> * 
        comparer : IComparer<'TValue> -> 'TSource 

Parameters

 

source
Type: System.Collections.Generic.IEnumerable(TSource)
A sequence of values to determine the maximum value of.
selector
Type: System.Func(TSource, TValue)
A transform function to apply to each element.
comparer
Type: System.Collections.Generic.IComparer(TValue)
The IComparer(T) to compare values.

Type Parameters

 

TSource
The type of the elements of source.
TValue
Type of the value

Return Value

Type: TSource
The item with maximum value in the sequence.

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

Reference

EnumerableExtensions Class
MaxBy Overload
CodeJam.Collections Namespace

Clone this wiki locally