I have some types S
and T
(e.g. S=object
and T=string
).
I have a pair of arrays of these types, i.e.
(S[], T[]) pairOfArrays;
and I want to convert it to an array of pairs, i.e.
(S, T)[] arrayOfPairs;
How do I do that? I am most interested in solutions with LINQ, if possible.
Please assume that the two arrays in pairOfArrays
have the same length.
I know the other direction:
pairOfArrays = (arrayOfPairs.Select(i => i.Item1).ToArray(),
arrayOfPairs.Select(i => i.Item2).ToArray());
The problem I have with the sought direction is: in order to iterate (use Select
and such) I need an IEnumerable
, but (S[], T[])
is no IEnumerable
. And if I start with pairOfArrays.Item1.Select(...
, then I don't know how to get to the same entry (index-wise) of Item2
as I currently have inside my Select
statement.