,--1,System.Func{--1,--0,--1})} ,--1,System.Func{--1,--0,--1},System.Func{--1,--2})} ,System.Func{--0,--0,--0})}
Observable.Aggregate(IObservable, TAccumulate, Func) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IObservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator) - 2.
public static IObservable<TResult> Aggregate<TSource, TAccumulate, TResult>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector) - 3.
public static IObservable<TSource> Aggregate<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
1. Overload¶
public static IObservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
Summary: Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value. For aggregation behavior with incremental intermediate results, see Scan.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TAccumulate | The type of the result of the aggregation. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | An observable sequence to aggregate over. |
seed | TAccumulate | The initial accumulator value. |
accumulator | Func | An accumulator function to be invoked on each element. |
Returns: IObservable
Remarks
The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or accumulator is null. |
2. Overload¶
public static IObservable<TResult> Aggregate<TSource, TAccumulate, TResult>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector)
Summary: Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value, and the specified result selector function is used to select the result value.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TAccumulate | The type of the accumulator value. |
TResult | The type of the resulting value. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | An observable sequence to aggregate over. |
seed | TAccumulate | The initial accumulator value. |
accumulator | Func | An accumulator function to be invoked on each element. |
resultSelector | Func | A function to transform the final accumulator value into the result value. |
Returns: IObservable
Remarks
The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or accumulator or resultSelector is null. |
3. Overload¶
public static IObservable<TSource> Aggregate<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
Summary: Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. For aggregation behavior with incremental intermediate results, see Scan.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence and the result of the aggregation. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | An observable sequence to aggregate over. |
accumulator | Func | An accumulator function to be invoked on each element. |
Returns: IObservable
Remarks
The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or accumulator is null. |
| System.InvalidOperationException | (Asynchronous) The source sequence is empty. |