Say I have a data structure of IEnumerable<IEnumerable<object>>
like this:
{
{ A, B }
{ 1, 2, 3 }
{ Z }
}
Where the outer array can contain any number of inner arrays. And the inner arrays can each independently contain any number of elements. And assume, for the sake of simplicity, that no array will be empty.
And I want to transform it to a IEnumerable<IEnumerable<object>>
like this:
{ { A, 1, Z }, { A, 2, Z }, { A, 3, Z }, { B, 1, Z }, { B, 2, Z }, { B, 3, Z } }
Which contains every combination of the values from the original structure. So each element in each inner array maps by index to an element/array in the original outer array.
What is the simplest way to do that in C#?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…