CartesianExtensionCartesianT1, T2, TResult(IEnumerableT1, IEnumerableT2, FuncT1, T2, TResult) Method
Returns the Cartesian product of two 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.ExtensionsAssembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
public static IEnumerable<TResult> Cartesian<T1, T2, TResult>(
this IEnumerable<T1> first,
IEnumerable<T2> second,
Func<T1, T2, TResult> resultSelector
)
<ExtensionAttribute>
Public Shared Function Cartesian(Of T1, T2, TResult) (
first As IEnumerable(Of T1),
second As IEnumerable(Of T2),
resultSelector As Func(Of T1, T2, TResult)
) As IEnumerable(Of TResult)
public:
[ExtensionAttribute]
generic<typename T1, typename T2, typename TResult>
static IEnumerable<TResult>^ Cartesian(
IEnumerable<T1>^ first,
IEnumerable<T2>^ second,
Func<T1, T2, TResult>^ resultSelector
)
[<ExtensionAttribute>]
static member Cartesian :
first : IEnumerable<'T1> *
second : IEnumerable<'T2> *
resultSelector : Func<'T1, 'T2, 'TResult> -> IEnumerable<'TResult>
- first IEnumerableT1
- The first sequence of elements.
- second IEnumerableT2
- The second sequence of elements.
- resultSelector FuncT1, T2, TResult
- A projection function that combines
elements from all of the sequences.
- T1
-
The type of the elements of first.
- T2
-
The type of the elements of second.
- TResult
-
The type of the elements of the result sequence.
IEnumerableTResultA sequence of elements returned by
resultSelector.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).
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.