Skip to content

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

Observable.Average(IObservable) method

Defined in

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

Applies to

netstandard2.0

Overloads

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

1. Overload

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

Summary: Computes the average of an observable sequence of Double values.

Parameters

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

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.

2. Overload

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

Summary: Computes the average of an observable sequence of Single values.

Parameters

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

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.

3. Overload

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

Summary: Computes the average of an observable sequence of Decimal values.

Parameters

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

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

4. Overload

public static IObservable<double> Average(this IObservable<int> source)

Summary: Computes the average of an observable sequence of Int32 values.

Parameters

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

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

5. Overload

public static IObservable<double> Average(this IObservable<long> source)

Summary: Computes the average of an observable sequence of Int64 values.

Parameters

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

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

6. Overload

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

Summary: Computes the average of an observable sequence of nullable Double values.

Parameters

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

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.

7. Overload

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

Summary: Computes the average of an observable sequence of nullable Single values.

Parameters

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

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.

8. Overload

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

Summary: Computes the average of an observable sequence of nullable Decimal values.

Parameters

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

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

9. Overload

public static IObservable<double?> Average(this IObservable<int?> source)

Summary: Computes the average of an observable sequence of nullable Int32 values.

Parameters

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

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

10. Overload

public static IObservable<double?> Average(this IObservable<long?> source)

Summary: Computes the average of an observable sequence of nullable Int64 values.

Parameters

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

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the elements in the source sequence is larger than MaxValue.

11. Overload

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

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.

12. Overload

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

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.

13. Overload

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

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.

14. Overload

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

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.
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<double> Average<TSource>(this IObservable<TSource> source, Func<TSource, long> selector)

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

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

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.InvalidOperationException(Asynchronous) The source sequence is empty.
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<decimal?> Average<TSource>(this IObservable<TSource> source, Func<TSource, decimal?> selector)

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.

17. Overload

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

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.

18. Overload

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

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.

19. Overload

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

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.
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<double?> Average<TSource>(this IObservable<TSource> source, Func<TSource, long?> selector)

Summary: Computes the average of an observable 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 to calculate the average of.
selectorFuncA transform function to apply to each element.

Returns: IObservable -- An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.

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.InvalidOperationException(Asynchronous) The source sequence is empty.
System.OverflowException(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than MaxValue.