Click or drag to resize

MoreEnumerableCartesianT1, T2, T3, TResult Method (IEnumerableT1, IEnumerableT2, IEnumerableT3, FuncT1, T2, T3, TResult)

Returns the Cartesian product of three sequences by enumerating all possible combinations of one item from each sequence, and applying a user-defined projection to the items in a given combination.

Namespace:  MoreLinq
Assembly:  MoreLinq (in MoreLinq.dll) Version: 3.0.0
Syntax
public static IEnumerable<TResult> Cartesian<T1, T2, T3, TResult>(
	this IEnumerable<T1> first,
	IEnumerable<T2> second,
	IEnumerable<T3> third,
	Func<T1, T2, T3, TResult> resultSelector
)

Parameters

first
Type: System.Collections.GenericIEnumerableT1
The first sequence of elements.
second
Type: System.Collections.GenericIEnumerableT2
The second sequence of elements.
third
Type: System.Collections.GenericIEnumerableT3
The third sequence of elements.
resultSelector
Type: SystemFuncT1, T2, T3, TResult
A projection function that combines elements from all of the sequences.

Type Parameters

T1
The type of the elements of first.
T2
The type of the elements of second.
T3
The type of the elements of third.
TResult
The type of the elements of the result sequence.

Return Value

Type: IEnumerableTResult
A sequence of elements returned by resultSelector.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableT1. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks

The method returns items in the same order as a nested foreach loop, but all sequences except for first are cached when iterated over. The cache is then re-used for any subsequent iterations.

This method uses deferred execution and stream its results.

See Also