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. |
Computes the sum of the sequence.
function Sum: T
Returns
The sum of all elements in the sequence.
Exceptions
T is not a supported numeric type.
Remarks
Returns 0 when the sequence is empty.
Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence.
function Sum(const selector: Func<T, Integer>): Integer
Parameters
- selector
- Func<T, Integer>
A transform function to apply to each element.
Returns
The sum of the projected values.
Exceptions
selector is nil .
The sum of the elements in the sequence is larger than Int32.MaxValue.
Computes the sum of the sequence of Int64 values that are obtained by invoking a transform function on each element of the input sequence.
function Sum(const selector: Func<T, Int64>): Int64
Parameters
- selector
- Func<T, Int64>
A transform function to apply to each element.
Returns
The sum of the projected values.
Exceptions
selector is nil .
The sum of the elements in the sequence is larger than Int64.MaxValue.
Computes the sum of the sequence of Single values that are obtained by invoking a transform function on each element of the input sequence.
function Sum(const selector: Func<T, Single>): Single
Parameters
- selector
- Func<T, Single>
A transform function to apply to each element.
Returns
The sum of the projected values.
Exceptions
selector is nil .
Computes the sum of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence.
function Sum(const selector: Func<T, Double>): Double
Parameters
- selector
- Func<T, Double>
A transform function to apply to each element.
Returns
The sum of the projected values.
Exceptions
selector is nil .
Computes the sum of the sequence of Currency values that are obtained by invoking a transform function on each element of the input sequence.
function Sum(const selector: Func<T, Currency>): Currency
Parameters
- selector
- Func<T, Currency>
A transform function to apply to each element.
Returns
The sum of the projected values.
Exceptions
selector is nil .