CartesianExtension.Cartesian<T1, T2, T3, T4, T5, T6, T7, TResult>(IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, IEnumerable<T4>, IEnumerable<T5>, IEnumerable<T6>, IEnumerable<T7>, Func<T1, T2, T3, T4, T5, T6, T7, TResult>) Method

Returns the Cartesian product of seven 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.

Definition

Namespace: MoreLinq.Extensions
Assembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
C#
public static IEnumerable<TResult> Cartesian<T1, T2, T3, T4, T5, T6, T7, TResult>(
	this IEnumerable<T1> first,
	IEnumerable<T2> second,
	IEnumerable<T3> third,
	IEnumerable<T4> fourth,
	IEnumerable<T5> fifth,
	IEnumerable<T6> sixth,
	IEnumerable<T7> seventh,
	Func<T1, T2, T3, T4, T5, T6, T7, TResult> resultSelector
)

Parameters

first  IEnumerable<T1>
The first sequence of elements.
second  IEnumerable<T2>
The second sequence of elements.
third  IEnumerable<T3>
The third sequence of elements.
fourth  IEnumerable<T4>
The fourth sequence of elements.
fifth  IEnumerable<T5>
The fifth sequence of elements.
sixth  IEnumerable<T6>
The sixth sequence of elements.
seventh  IEnumerable<T7>
The seventh sequence of elements.
resultSelector  Func<T1, T2, T3, T4, T5, T6, T7, 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.
T4
The type of the elements of fourth.
T5
The type of the elements of fifth.
T6
The type of the elements of sixth.
T7
The type of the elements of seventh.
TResult
The type of the elements of the result sequence.

Return Value

IEnumerable<TResult>
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 IEnumerable<T1>. 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