Click or drag to resize

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

Returns a projection of tuples, where each tuple contains the N-th element from each of the argument sequences. The resulting sequence will always be as long as the longest of input sequences where the default value of each of the shorter sequence element types is used for padding.

Namespace:  MoreLinq
Assembly:  MoreLinq (in MoreLinq.dll) Version: 3.3.1+b77df70598ab84c28cd43dcf74594024b6d575e1
Syntax
public static IEnumerable<TResult> ZipLongest<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.
second
Type: System.Collections.GenericIEnumerableT2
The second sequence.
third
Type: System.Collections.GenericIEnumerableT3
The third sequence.
resultSelector
Type: SystemFuncT1, T2, T3, TResult
Function to apply to each triplet 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.
TResult
Type of elements in result sequence.

Return Value

Type: IEnumerableTResult
A sequence that contains elements of the three 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 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
This operator uses deferred execution and streams its results.
Examples
var numbers = new[] { 1, 2, 3 };
var letters = new[] { "A", "B", "C", "D" };
var chars   = new[] { 'a', 'b', 'c', 'd', 'e' };
var zipped  = numbers.ZipLongest(letters, chars, (n, l, c) => n + l + c);
The zipped variable, when iterated over, will yield "1Aa", "2Bb", "3Cc", "0Dd", "0e" in turn.
See Also