public static IEnumerable<TResult> ZipShortest<TFirst, TSecond, TResult>(
this IEnumerable<TFirst> first,
IEnumerable<TSecond> second,
Func<TFirst, TSecond, TResult> resultSelector
)
<ExtensionAttribute>
Public Shared Function ZipShortest(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>^ ZipShortest(
IEnumerable<TFirst>^ first,
IEnumerable<TSecond>^ second,
Func<TFirst, TSecond, TResult>^ resultSelector
)
[<ExtensionAttribute>]
static member ZipShortest :
first : IEnumerable<'TFirst> *
second : IEnumerable<'TSecond> *
resultSelector : Func<'TFirst, 'TSecond, 'TResult> -> IEnumerable<'TResult>
If the input sequences are of different lengths, the result sequence is terminated as soon as the shortest input sequence is exhausted and remainder elements from the longer sequences are never consumed.
This operator uses deferred execution and streams its results.
var numbers = new[] { 1, 2, 3 };
var letters = new[] { "A", "B", "C", "D" };
var zipped = numbers.ZipShortest(letters, (n, l) => n + l);