Computes the sum of the sequence of values that are obtained
by invoking a transform function on each element of the input sequence.
Namespace:
Extreme.Mathematics
Assembly:
Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.1
public static U Sum<T, U>(
this IEnumerable<T> source,
Func<T, U> selector
)
<ExtensionAttribute>
Public Shared Function Sum(Of T, U) (
source As IEnumerable(Of T),
selector As Func(Of T, U)
) As U
public:
[ExtensionAttribute]
generic<typename T, typename U>
static U Sum(
IEnumerable<T>^ source,
Func<T, U>^ selector
)
[<ExtensionAttribute>]
static member Sum :
source : IEnumerable<'T> *
selector : Func<'T, 'U> -> 'U
Parameters
- source
- Type: System.Collections.GenericIEnumerableT
A sequence of values. - selector
- Type: SystemFuncT, U
A transform function to apply to each element.
Type Parameters
- T
- The element type of source.
- U
- The type of the result.
Return Value
Type:
UThe sum of the projected values.
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).
Reference