I have an array of IEnumerable (IEnumerable[]) and would like to generate all possible combinations of the elements in these IEnumerables. It is similar to this problem: Generating Permutations using LINQ but I do not know how many IEnumerables I will have beforehand and thus cannot use the described LINQ statement.
To give an example: My array
IEnumerable[] array;
has for example these elements
array[0]={0,1,2};
array[1]={a,b};
Then I would like these to be returned:
{{0,a},{0,b},{1,a},{1,b},{2,a},{2,b}}
But it might also hold:
array[0]={0,1,2};
array[1]={a,b};
array[2]={w,x,y,z};
Then I would need the appropriate permutations. I do not have any information on how many IEnumerables and no information on how many elements each IEnumerable holds.
Thanks in advance for any help,
Lars