Skip to content

,System.IObservable{--1})} ,System.Func{--0,System.IObservable{--1}})} ,System.Func{--0,System.Int32,System.IObservable{--1}})} ,System.Func{--0,System.Threading.Tasks.Task{--1}})} ,System.Func{--0,System.Int32,System.Threading.Tasks.Task{--1}})} ,System.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.Task{--1}})} ,System.Func{--0,System.Int32,System.Threading.CancellationToken,System.Threading.Tasks.Task{--1}})} ,System.Func{--0,System.IObservable{--1}},System.Func{--0,--1,--2})} ,System.Func{--0,System.Int32,System.IObservable{--1}},System.Func{--0,System.Int32,--1,System.Int32,--2})} ,System.Func{--0,System.Threading.Tasks.Task{--1}},System.Func{--0,--1,--2})} ,System.Func{--0,System.Int32,System.Threading.Tasks.Task{--1}},System.Func{--0,System.Int32,--1,--2})} ,System.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.Task{--1}},System.Func{--0,--1,--2})} ,System.Func{--0,System.Int32,System.Threading.CancellationToken,System.Threading.Tasks.Task{--1}},System.Func{--0,System.Int32,--1,--2})} ,System.Func{--0,System.IObservable{--1}},System.Func{System.Exception,System.IObservable{--1}},System.Func{System.IObservable{--1}})} ,System.Func{--0,System.Int32,System.IObservable{--1}},System.Func{System.Exception,System.IObservable{--1}},System.Func{System.IObservable{--1}})} ,System.Func{--0,System.Collections.Generic.IEnumerable{--1}})} ,System.Func{--0,System.Int32,System.Collections.Generic.IEnumerable{--1}})} ,System.Func{--0,System.Collections.Generic.IEnumerable{--1}},System.Func{--0,--1,--2})} ,System.Func{--0,System.Int32,System.Collections.Generic.IEnumerable{--1}},System.Func{--0,System.Int32,--1,System.Int32,--2})}

Observable.SelectMany(IObservable, IObservable) method

Defined in

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

Applies to

netstandard2.0

Overloads

  • 1. public static IObservable<TOther> SelectMany<TSource, TOther>(this IObservable<TSource> source, IObservable<TOther> other)
  • 2. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, IObservable<TResult>> selector)
  • 3. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TResult>> selector)
  • 4. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, Task<TResult>> selector)
  • 5. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, Task<TResult>> selector)
  • 6. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, CancellationToken, Task<TResult>> selector)
  • 7. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, CancellationToken, Task<TResult>> selector)
  • 8. public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, IObservable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
  • 9. public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TCollection>> collectionSelector, Func<TSource, int, TCollection, int, TResult> resultSelector)
  • 10. public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, Task<TTaskResult>> taskSelector, Func<TSource, TTaskResult, TResult> resultSelector)
  • 11. public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, int, Task<TTaskResult>> taskSelector, Func<TSource, int, TTaskResult, TResult> resultSelector)
  • 12. public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, CancellationToken, Task<TTaskResult>> taskSelector, Func<TSource, TTaskResult, TResult> resultSelector)
  • 13. public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, int, CancellationToken, Task<TTaskResult>> taskSelector, Func<TSource, int, TTaskResult, TResult> resultSelector)
  • 14. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, IObservable<TResult>> onNext, Func<Exception, IObservable<TResult>> onError, Func<IObservable<TResult>> onCompleted)
  • 15. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TResult>> onNext, Func<Exception, IObservable<TResult>> onError, Func<IObservable<TResult>> onCompleted)
  • 16. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, IEnumerable<TResult>> selector)
  • 17. public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, IEnumerable<TResult>> selector)
  • 18. public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
  • 19. public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, int, TCollection, int, TResult> resultSelector)

1. Overload

public static IObservable<TOther> SelectMany<TSource, TOther>(this IObservable<TSource> source, IObservable<TOther> other)

Summary: Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TOtherThe type of the elements in the other sequence and the elements in the result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
otherIObservableAn observable sequence to project each element from the source sequence onto.

Returns: IObservable -- An observable sequence whose elements are the result of projecting each source element onto the other sequence and merging all the resulting sequences together.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or other is null.

2. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, IObservable<TResult>> selector)

Summary: Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements in the projected inner sequences and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
selectorFunc>A transform function to apply to each element.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

3. Overload

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

Summary: Projects each element of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements in the projected inner sequences and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
selectorFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

4. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, Task<TResult>> selector)

Summary: Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the result produced by the projected tasks and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
selectorFunc>A transform function to apply to each element.

Returns: IObservable -- An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.

Remarks

This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using ToObservable.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

5. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, Task<TResult>> selector)

Summary: Projects each element of an observable sequence to a task by incorporating the element's index and merges all of the task results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the result produced by the projected tasks and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
selectorFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.

Returns: IObservable -- An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.

Remarks

This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using ToObservable.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

6. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, CancellationToken, Task<TResult>> selector)

Summary: Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the result produced by the projected tasks and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
selectorFunc>A transform function to apply to each element.

Returns: IObservable -- An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.

Remarks

This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using ToObservable.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

7. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, CancellationToken, Task<TResult>> selector)

Summary: Projects each element of an observable sequence to a task by incorporating the element's index with cancellation support and merges all of the task results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the result produced by the projected tasks and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
selectorFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.

Returns: IObservable -- An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.

Remarks

This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using ToObservable.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

8. Overload

public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, IObservable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)

Summary: Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TCollectionThe type of the elements in the projected intermediate sequences.
TResultThe type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
collectionSelectorFunc>A transform function to apply to each element.
resultSelectorFuncA transform function to apply to each element of the intermediate sequence.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or collectionSelector or resultSelector is null.

9. Overload

public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TCollection>> collectionSelector, Func<TSource, int, TCollection, int, TResult> resultSelector)

Summary: Projects each element of an observable sequence to an observable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TCollectionThe type of the elements in the projected intermediate sequences.
TResultThe type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
collectionSelectorFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.
resultSelectorFuncA transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or collectionSelector or resultSelector is null.

10. Overload

public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, Task<TTaskResult>> taskSelector, Func<TSource, TTaskResult, TResult> resultSelector)

Summary: Projects each element of an observable sequence to a task, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TTaskResultThe type of the results produced by the projected intermediate tasks.
TResultThe type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
taskSelectorFunc>A transform function to apply to each element.
resultSelectorFuncA transform function to apply to each element of the intermediate sequence.

Returns: IObservable -- An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.

Remarks

This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using ToObservable.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or taskSelector or resultSelector is null.

11. Overload

public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, int, Task<TTaskResult>> taskSelector, Func<TSource, int, TTaskResult, TResult> resultSelector)

Summary: Projects each element of an observable sequence to a task by incorporating the element's index, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TTaskResultThe type of the results produced by the projected intermediate tasks.
TResultThe type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
taskSelectorFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.
resultSelectorFuncA transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element.

Returns: IObservable -- An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.

Remarks

This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using ToObservable.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or taskSelector or resultSelector is null.

12. Overload

public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, CancellationToken, Task<TTaskResult>> taskSelector, Func<TSource, TTaskResult, TResult> resultSelector)

Summary: Projects each element of an observable sequence to a task with cancellation support, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TTaskResultThe type of the results produced by the projected intermediate tasks.
TResultThe type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
taskSelectorFunc>A transform function to apply to each element.
resultSelectorFuncA transform function to apply to each element of the intermediate sequence.

Returns: IObservable -- An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.

Remarks

This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using ToObservable.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or taskSelector or resultSelector is null.

13. Overload

public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, int, CancellationToken, Task<TTaskResult>> taskSelector, Func<TSource, int, TTaskResult, TResult> resultSelector)

Summary: Projects each element of an observable sequence to a task by incorporating the element's index with cancellation support, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TTaskResultThe type of the results produced by the projected intermediate tasks.
TResultThe type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
taskSelectorFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.
resultSelectorFuncA transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element.

Returns: IObservable -- An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.

Remarks

This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using ToObservable.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or taskSelector or resultSelector is null.

14. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, IObservable<TResult>> onNext, Func<Exception, IObservable<TResult>> onError, Func<IObservable<TResult>> onCompleted)

Summary: Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements in the projected inner sequences and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of notifications to project.
onNextFunc>A transform function to apply to each element.
onErrorFunc>A transform function to apply when an error occurs in the source sequence.
onCompletedFunc>A transform function to apply when the end of the source sequence is reached.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or onNext or onError or onCompleted is null.

15. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TResult>> onNext, Func<Exception, IObservable<TResult>> onError, Func<IObservable<TResult>> onCompleted)

Summary: Projects each notification of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements in the projected inner sequences and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of notifications to project.
onNextFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.
onErrorFunc>A transform function to apply when an error occurs in the source sequence.
onCompletedFunc>A transform function to apply when the end of the source sequence is reached.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or onNext or onError or onCompleted is null.

16. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, IEnumerable<TResult>> selector)

Summary: Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
selectorFunc>A transform function to apply to each element.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

Remarks

The projected sequences are enumerated synchronously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the ToObservable conversion.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

17. Overload

public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, IEnumerable<TResult>> selector)

Summary: Projects each element of an observable sequence to an enumerable sequence by incorporating the element's index and concatenates the resulting enumerable sequences into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
selectorFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

Remarks

The projected sequences are enumerated synchronously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the ToObservable conversion.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or selector is null.

18. Overload

public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)

Summary: Projects each element of an observable sequence to an enumerable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TCollectionThe type of the elements in the projected intermediate enumerable sequences.
TResultThe type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
collectionSelectorFunc>A transform function to apply to each element.
resultSelectorFuncA transform function to apply to each element of the intermediate sequence.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.

Remarks

The projected sequences are enumerated synchronously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the ToObservable conversion.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or collectionSelector or resultSelector is null.

19. Overload

public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, int, IEnumerable<TCollection>> collectionSelector, Func<TSource, int, TCollection, int, TResult> resultSelector)

Summary: Projects each element of an observable sequence to an enumerable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TCollectionThe type of the elements in the projected intermediate enumerable sequences.
TResultThe type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.

Parameters

NameTypeDescription
sourceIObservableAn observable sequence of elements to project.
collectionSelectorFunc>A transform function to apply to each element; the second parameter of the function represents the index of the source element.
resultSelectorFuncA transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.

Returns: IObservable -- An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.

Remarks

The projected sequences are enumerated synchronously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the ToObservable conversion.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or collectionSelector or resultSelector is null.