Zip3
Combines three collections into a collections of triples.
ParĂ¢metros
Retorno
IEnumerable<T> source
IEnumerable<T2> source2
IEnumerable<T3> source3
IEnumerable<(T, T2, T3)>
Usage
With same type and same length collections
//IEnumerable<int> source = { 1, 2, 3 }
//IEnumerable<int> source2 = { -1, -2, -3 }
//IEnumerable<int> source3 = { 0, 1, 0 }
IEnumerable<(int, int)> result = source.Zip3(source2, source3);
//result = { (1, -1, 0), (2, -2, 1), (3, -3, 0)}
With different types collections
//IEnumerable<int> source = { 1, 2, 3 }
//IEnumerable<bool> source2 = { false, true, true }
//IEnumerable<int> source3 = { 0, 1, 0 }
IEnumerable<(int, bool, int)> result = source.Zip3(source2, source3);
//result = { (1, false, 0), (2, true, 1), (3, true, 0)}
With different sized collections
//IEnumerable<int> source = { 1, 2, 3 }
//IEnumerable<string> source2 = { "One", "Two" }
//IEnumerable<int> source3 = { 0, 1, 0, 1 }
IEnumerable<(int, string, int)> result = source.Zip(source2);
//result = { (1, "One", 0), (2, "Two", 1)}
Last updated
Was this helpful?