Skip to content

)} )} )} )} )} })} })} })} })} })} ,System.Func{--0,System.Double})} ,System.Func{--0,System.Single})} ,System.Func{--0,System.Decimal})} ,System.Func{--0,System.Int32})} ,System.Func{--0,System.Int64})} ,System.Func{--0,System.Nullable{System.Double}})} ,System.Func{--0,System.Nullable{System.Single}})} ,System.Func{--0,System.Nullable{System.Decimal}})} ,System.Func{--0,System.Nullable{System.Int32}})} ,System.Func{--0,System.Nullable{System.Int64}})}

Observable.Sum(IObservable) method

Defined in

Type: Observable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IObservable<double> Sum(this IObservable<double> source)
  • 2. public static IObservable<float> Sum(this IObservable<float> source)
  • 3. public static IObservable<decimal> Sum(this IObservable<decimal> source)
  • 4. public static IObservable<int> Sum(this IObservable<int> source)
  • 5. public static IObservable<long> Sum(this IObservable<long> source)
  • 6. public static IObservable<double?> Sum(this IObservable<double?> source)
  • 7. public static IObservable<float?> Sum(this IObservable<float?> source)
  • 8. public static IObservable<decimal?> Sum(this IObservable<decimal?> source)
  • 9. public static IObservable<int?> Sum(this IObservable<int?> source)
  • 10. public static IObservable<long?> Sum(this IObservable<long?> source)
  • 11. public static IObservable<double> Sum<TSource>(this IObservable<TSource> source, Func<TSource, double> selector)
  • 12. public static IObservable<float> Sum<TSource>(this IObservable<TSource> source, Func<TSource, float> selector)
  • 13. public static IObservable<decimal> Sum<TSource>(this IObservable<TSource> source, Func<TSource, decimal> selector)
  • 14. public static IObservable<int> Sum<TSource>(this IObservable<TSource> source, Func<TSource, int> selector)
  • 15. public static IObservable<long> Sum<TSource>(this IObservable<TSource> source, Func<TSource, long> selector)
  • 16. public static IObservable<double?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, double?> selector)
  • 17. public static IObservable<float?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, float?> selector)
  • 18. public static IObservable<decimal?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, decimal?> selector)
  • 19. public static IObservable<int?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, int?> selector)
  • 20. public static IObservable<long?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, long?> selector)

1. Overload

public static IObservable<double> Sum(this IObservable<double> source)

Summary: Computes the sum of a sequence of Double values.

Parameters

NameTypeDescription
sourceIObservableA sequence of Double values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.

2. Overload

public static IObservable<float> Sum(this IObservable<float> source)

Summary: Computes the sum of a sequence of Single values.

Parameters

NameTypeDescription
sourceIObservableA sequence of Single values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.

3. Overload

public static IObservable<decimal> Sum(this IObservable<decimal> source)

Summary: Computes the sum of a sequence of Decimal values.

Parameters

NameTypeDescription
sourceIObservableA sequence of Decimal values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

4. Overload

public static IObservable<int> Sum(this IObservable<int> source)

Summary: Computes the sum of a sequence of Int32 values.

Parameters

NameTypeDescription
sourceIObservableA sequence of Int32 values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

5. Overload

public static IObservable<long> Sum(this IObservable<long> source)

Summary: Computes the sum of a sequence of Int64 values.

Parameters

NameTypeDescription
sourceIObservableA sequence of Int64 values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

6. Overload

public static IObservable<double?> Sum(this IObservable<double?> source)

Summary: Computes the sum of a sequence of nullable Double values.

Parameters

NameTypeDescription
sourceIObservableA sequence of nullable Double values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.

7. Overload

public static IObservable<float?> Sum(this IObservable<float?> source)

Summary: Computes the sum of a sequence of nullable Single values.

Parameters

NameTypeDescription
sourceIObservableA sequence of nullable Single values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.

8. Overload

public static IObservable<decimal?> Sum(this IObservable<decimal?> source)

Summary: Computes the sum of a sequence of nullable Decimal values.

Parameters

NameTypeDescription
sourceIObservableA sequence of nullable Decimal values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

9. Overload

public static IObservable<int?> Sum(this IObservable<int?> source)

Summary: Computes the sum of a sequence of nullable Int32 values.

Parameters

NameTypeDescription
sourceIObservableA sequence of nullable Int32 values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

10. Overload

public static IObservable<long?> Sum(this IObservable<long?> source)

Summary: Computes the sum of a sequence of nullable Int64 values.

Parameters

NameTypeDescription
sourceIObservableA sequence of nullable Int64 values to calculate the sum of.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

11. Overload

public static IObservable<double> Sum<TSource>(this IObservable<TSource> source, Func<TSource, double> selector)

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

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

12. Overload

public static IObservable<float> Sum<TSource>(this IObservable<TSource> source, Func<TSource, float> selector)

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

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

13. Overload

public static IObservable<decimal> Sum<TSource>(this IObservable<TSource> source, Func<TSource, decimal> selector)

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

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.

14. Overload

public static IObservable<int> Sum<TSource>(this IObservable<TSource> source, Func<TSource, int> selector)

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

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.

15. Overload

public static IObservable<long> Sum<TSource>(this IObservable<TSource> source, Func<TSource, long> selector)

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

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.

16. Overload

public static IObservable<double?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, double?> selector)

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

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

17. Overload

public static IObservable<float?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, float?> selector)

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

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

18. Overload

public static IObservable<decimal?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, decimal?> selector)

Summary: Computes the sum of a sequence of nullable Decimal values that are obtained by invoking a transform function on each element of the input sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.

19. Overload

public static IObservable<int?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, int?> selector)

Summary: Computes the sum of a sequence of nullable Int32 values that are obtained by invoking a transform function on each element of the input sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.

20. Overload

public static IObservable<long?> Sum<TSource>(this IObservable<TSource> source, Func<TSource, long?> selector)

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

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableA sequence of values that are used to calculate a sum.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the sum of the values in the source sequence.

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.