Returns a projection of tuples, where each tuple contains the N-th element
from each of the argument sequences.
Declaration Syntax
C# | Visual Basic | Visual C++ |
public static IEnumerable<TResult> Zip<TFirst, TSecond, TResult>( this IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector )
<ExtensionAttribute> _ Public Shared Function Zip(Of TFirst, TSecond, TResult) ( _ first As IEnumerable(Of TFirst), _ second As IEnumerable(Of TSecond), _ resultSelector As Func(Of TFirst, TSecond, TResult) _ ) As IEnumerable(Of TResult)
public: [ExtensionAttribute] generic<typename TFirst, typename TSecond, typename TResult> static IEnumerable<TResult>^ Zip( IEnumerable<TFirst>^ first, IEnumerable<TSecond>^ second, Func<TFirst, TSecond, TResult>^ resultSelector )
Generic Template Parameters
- TFirst
- Type of elements in first sequence
- TSecond
- Type of elements in second sequence
- TResult
- Type of elements in result sequence
Parameters
- first (IEnumerable<(Of <(<'TFirst>)>)>)
- First sequence
- second (IEnumerable<(Of <(<'TSecond>)>)>)
- Second sequence
- resultSelector (Func<(Of <(<'TFirst, TSecond, TResult>)>)>)
- Function to apply to each pair of elements
Return Value
[Missing <returns> documentation for "M:MoreLinq.MoreEnumerable.Zip``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``1,``2})"]
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'TFirst>)>)>. When you use instance method syntax to call this method, omit the first parameter.
Remarks
If the two input sequences are of different lengths, the result sequence
is terminated as soon as the shortest input sequence is exhausted.
This operator uses deferred execution and streams its results.
Examples
Copy | |
---|---|
int[] numbers = { 1, 2, 3 }; string[] letters = { "A", "B", "C", "D" }; var zipped = numbers.Zip(letters, (n, l) => n + l); |
Assembly: MoreLinq (Module: MoreLinq.dll) Version: 1.0.16006.0 (1.0.16006.1845)