Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 1.37 KB

zip-shortest.md

File metadata and controls

33 lines (24 loc) · 1.37 KB

ZipShortest

Returns a projection of tuples, where each tuple contains the N-th element from each of the argument sequences. The resulting sequence is as short as the shortest input sequence.

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 };
var zipped  = numbers.ZipShortest(letters, chars, flags, (n, l, c, f) => n + l + c + f);
WriteLine(zipped);

See also Exploring MoreLINQ Part 1 - Zipping by Mark Heath and his video that covers ZipShortest:

Video by Mark Heath

For more details, see the documentation.


✏ Edit this page if you see a typo or wish to contribute an improvement. Alternatively, you can also report an issue you see.