Click or drag to resize

EnumerableExtensionsMaxElementT, M Method

Gets the element of a IEnumerabe that evaluates by means of a conversion function to the maximal value. This is different from Select(x => conversion(x)).Max() insofar as it not returns the maximum value, but the original element x which converts to the maximum value.

Namespace: Altaxo.Collections
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax
C#
public static T MaxElement<T, M>(
	this IEnumerable<T> org,
	Func<T, M> conversion
)
where M : Object, IComparable<M>

Parameters

org  IEnumerableT
The enumeration to consider.
conversion  FuncT, M
Conversion function that converts each element (type: T) of the sequence to a value (of type M that is comparable.

Type Parameters

T
Type of the elements of the enumeration.
M
Type of the value that is used to compare the elements of the sequence.

Return Value

T
This element of the sequence, which by the provided conversion function evaluates to the maximum value.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableT. 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).
Exceptions
ExceptionCondition
InvalidOperationExceptionThe provided enumeration is empty. Thus it is not possible to evaluate the maximum.
See Also