Click or drag to resize

EnumerableExtensionsIndexOfMaxT Method

Return the index of the element with the maximum value in an enumerable. If multiple elements with the same maximal value exist, the index of the first element in the sequence is returned.

Namespace: Altaxo.Collections
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3572.0 (4.8.3572.0)
Syntax
C#
public static int IndexOfMax<T>(
	this IEnumerable<T> elements,
	Func<T, double> transformer
)

Parameters

elements  IEnumerableT
The input elements.
transformer  FuncT, Double
The function that transforms the elements to a numerical value.

Type Parameters

T
The element type of the sequence.

Return Value

Int32
The index of the first element with the maximum transformed value. Returns -1 if the element enumeration is empty or contains only nonvalid elements (NaN).

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).
See Also