Unzip

Splits a collection of pairs into two collections.

Parâmetros

Retorno

IEnumerable<(T, T2)> source

(IEnumerable<T>, IEnumerable<T2>)

Usage

With same type collections

//IEnumerable<int, int> source = { (1, 2), (3, 4) }

var (resultLeft, resultRight) = source.Unzip();

//resultLeft =  { 1, 3 }
//resultRight = { 2, 4 }

With different types collections

//IEnumerable<int, bool> source = { (1, true), (2, false)}

var (resultLeft, resultRight) = source.Unzip();

//resultLeft =  { 1, 2 }
//resultRight = { true, false }

Last updated