IEnumerable<T>.Sum Method

Overloads

Sum

Computes the sum of the sequence.

Sum(Func<T,Integer>)

Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence.

Sum(Func<T,Int64>)

Computes the sum of the sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence.

Sum(Func<T,Single>)

Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence.

Sum(Func<T,Double>)

Computes the sum of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence.

Sum(Func<T,Currency>)

Computes the sum of the sequence of Currency values that are obtained by invoking a transform function on each element of the input sequence.

Sum

Computes the sum of the sequence.

Delphi
function Sum: T

Returns

T

The sum of all elements in the sequence.

Exceptions

T is not a supported numeric type.

Remarks

Returns 0 when the sequence is empty.

Sum(Func<T,Integer>)

Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence.

Delphi
function Sum(const selector: Func<T, Integer>): Integer

Parameters

selector
Func<T, Integer>

A transform function to apply to each element.

Returns

Integer

The sum of the projected values.

Exceptions

selector is nil .

The sum of the elements in the sequence is larger than Int32.MaxValue.

Sum(Func<T,Int64>)

Computes the sum of the sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence.

Delphi
function Sum(const selector: Func<T, Int64>): Int64

Parameters

selector
Func<T, Int64>

A transform function to apply to each element.

Returns

Int64

The sum of the projected values.

Exceptions

selector is nil .

The sum of the elements in the sequence is larger than Int64.MaxValue.

Sum(Func<T,Single>)

Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence.

Delphi
function Sum(const selector: Func<T, Single>): Single

Parameters

selector
Func<T, Single>

A transform function to apply to each element.

Returns

Single

The sum of the projected values.

Exceptions

selector is nil .

Sum(Func<T,Double>)

Computes the sum of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence.

Delphi
function Sum(const selector: Func<T, Double>): Double

Parameters

selector
Func<T, Double>

A transform function to apply to each element.

Returns

Double

The sum of the projected values.

Exceptions

selector is nil .

Sum(Func<T,Currency>)

Computes the sum of the sequence of Currency values that are obtained by invoking a transform function on each element of the input sequence.

Delphi
function Sum(const selector: Func<T, Currency>): Currency

Parameters

selector
Func<T, Currency>

A transform function to apply to each element.

Returns

Currency

The sum of the projected values.

Exceptions

selector is nil .