SelectMany(TSource, TCollection, TResult) Method (ParallelQuery(TSource), Func(TSource, Int32, IEnumerable(TCollection)), Func(TSource, TCollection, TResult))

Task Parallel System.Threading

Projects each element of a sequence to an IEnumerable{T}, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein. The index of each source element is used in the intermediate projected form of that element.

Namespace:  System.Linq
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function SelectMany(Of TSource, TCollection, TResult) ( _
	source As ParallelQuery(Of TSource), _
	collectionSelector As Func(Of TSource, Integer, IEnumerable(Of TCollection)), _
	resultSelector As Func(Of TSource, TCollection, TResult) _
) As ParallelQuery(Of TResult)
C#
public static ParallelQuery<TResult> SelectMany<TSource, TCollection, TResult>(
	ParallelQuery<TSource> source,
	Func<TSource, int, IEnumerable<TCollection>> collectionSelector,
	Func<TSource, TCollection, TResult> resultSelector
)

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
A sequence of values to project.
collectionSelector
Type: System..::.Func<(Of <(TSource, Int32, IEnumerable<(Of <(TCollection>)>)>)>)
A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
resultSelector
Type: System..::.Func<(Of <(TSource, TCollection, TResult>)>)
A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

Type Parameters

TSource
The type of elements of source.
TCollection
The type of the intermediate elements collected by collectionSelector.
TResult
The type of elements to return.

Return Value

A sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of source and then mapping each of those sequence elements and their corresponding source element to a result element.

Exceptions

ExceptionCondition
System..::.ArgumentNullException source or collectionSelector or resultSelector is a null reference (Nothing in Visual Basic).

See Also