Click or drag to resize

MoreEnumerable.EquiZip<T1, T2, T3, T4, TResult> Method (IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, IEnumerable<T4>, Func<T1, T2, T3, T4, TResult>)

Returns a projection of tuples, where each tuple contains the N-th element from each of the argument sequences.

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

Parameters

first
Type: System.Collections.Generic.IEnumerable<T1>
First sequence
second
Type: System.Collections.Generic.IEnumerable<T2>
Second sequence
third
Type: System.Collections.Generic.IEnumerable<T3>
Third sequence
fourth
Type: System.Collections.Generic.IEnumerable<T4>
Fourth sequence
resultSelector
Type: System.Func<T1, T2, T3, T4, TResult>
Function to apply to each quadruplet of elements

Type Parameters

T1
Type of elements in first sequence
T2
Type of elements in second sequence
T3
Type of elements in third sequence
T4
Type of elements in fourth sequence
TResult
Type of elements in result sequence

Return Value

Type: IEnumerable<TResult>
A sequence that contains elements of the four input sequences, combined 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
If the three input sequences are of different lengths then InvalidOperationException is thrown. This operator uses deferred execution and streams its results.
Examples
var numbers = { 1, 2, 3, 4 };
var letters = { "A", "B", "C", "D" };
var chars   = { 'a', 'b', 'c', 'd' };
var flags   = { true, false, true, false };
var zipped = numbers.EquiZip(letters, chars, flags, (n, l, c, f) => n + l + c + f);
The zipped variable, when iterated over, will yield "1AaTrue", "2BbFalse", "3CcTrue", "4DdFalse" in turn.
See Also