ZipLongestExtensionZipLongestTFirst, TSecond, TResult(IEnumerableTFirst, IEnumerableTSecond, FuncTFirst, TSecond, TResult) Method
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.ExtensionsAssembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
public static IEnumerable<TResult> ZipLongest<TFirst, TSecond, TResult>(
this IEnumerable<TFirst> first,
IEnumerable<TSecond> second,
Func<TFirst, TSecond, TResult> resultSelector
)
<ExtensionAttribute>
Public Shared Function ZipLongest(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>^ ZipLongest(
IEnumerable<TFirst>^ first,
IEnumerable<TSecond>^ second,
Func<TFirst, TSecond, TResult>^ resultSelector
)
[<ExtensionAttribute>]
static member ZipLongest :
first : IEnumerable<'TFirst> *
second : IEnumerable<'TSecond> *
resultSelector : Func<'TFirst, 'TSecond, 'TResult> -> IEnumerable<'TResult>
- first IEnumerableTFirst
- The first sequence.
- second IEnumerableTSecond
- The second sequence.
- resultSelector FuncTFirst, TSecond, TResult
-
Function to apply to each pair of elements.
- TFirst
- Type of elements in first sequence.
- TSecond
- Type of elements in second sequence.
- TResult
- Type of elements in result sequence.
IEnumerableTResult
A sequence that contains elements of the two input sequences,
combined by
resultSelector.
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableTFirst. 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).
This operator uses deferred execution and streams its results.
var numbers = { 1, 2, 3 };
var letters = { "A", "B", "C", "D" };
var zipped = numbers.ZipLongest(letters, (n, l) => n + l);
The
zipped variable, when iterated over, will yield "1A",
"2B", "3C", "0D" in turn.