ZipLongestExtensionZipLongestT1, T2, T3, T4, TResult Method (IEnumerableT1, IEnumerableT2, IEnumerableT3, IEnumerableT4, FuncT1, 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.Extensions
Assembly:
MoreLinq (in MoreLinq.dll) Version: 3.0.0
Syntax public static IEnumerable<TResult> ZipLongest<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
)
<ExtensionAttribute>
Public Shared Function ZipLongest(Of T1, T2, T3, T4, TResult) (
first As IEnumerable(Of T1),
second As IEnumerable(Of T2),
third As IEnumerable(Of T3),
fourth As IEnumerable(Of T4),
resultSelector As Func(Of T1, T2, T3, T4, TResult)
) As IEnumerable(Of TResult)
public:
[ExtensionAttribute]
generic<typename T1, typename T2, typename T3, typename T4, typename TResult>
static IEnumerable<TResult>^ ZipLongest(
IEnumerable<T1>^ first,
IEnumerable<T2>^ second,
IEnumerable<T3>^ third,
IEnumerable<T4>^ fourth,
Func<T1, T2, T3, T4, TResult>^ resultSelector
)
[<ExtensionAttribute>]
static member ZipLongest :
first : IEnumerable<'T1> *
second : IEnumerable<'T2> *
third : IEnumerable<'T3> *
fourth : IEnumerable<'T4> *
resultSelector : Func<'T1, 'T2, 'T3, 'T4, 'TResult> -> IEnumerable<'TResult>
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. - fourth
- Type: System.Collections.GenericIEnumerableT4
The fourth sequence. - resultSelector
- Type: SystemFuncT1, 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:
IEnumerableTResult
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
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
If the input sequences are of different lengths then the result
sequence will always be as long as the longest of input sequences.
The default value of the each shorter sequence element type is used
for padding.
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 flags = new[] { true, false, true, false, true, false };
var zipped = numbers.ZipLongest(letters, chars, flags, (n, l, c, f) => n + l + c + f);
The
zipped variable, when iterated over, will yield "1AaTrue",
"2BbFalse", "3CcTrue", "0DdFalse", "0eTrue", "0\0False" in turn.
See Also