I have some number of arrays which is unknown at programming time, maybe it is 3 or 4 or 7 ... each array has some elements, i.e,
a={1 2 3 4}
b={6 7 5 2 1}
c={22 4 6 8 4 8 5 4}
d={....}
e, f, g, ...
I want to get get all possible combinations by sampling one number from each array for example one case is that I pick up "1" from a, "7" from b, first "8" from c, d[3], e[5],... to make "1,7,8,d[3],e[5],...". It's not possible to use nested for loops because I don't know the number of arrays at compile time. If it was known for example 4 arrays (a,b,c,d) I could use 4 loops:
for (int i = 0; i <= a.Length-1; i++)
{
for (int j = 0; i <= b.Length-1; j++)
{
for (int k = 0; i <= c.Length-1; k++)
{
for (int m = 0; i <= d.Length-1; m++)
{
Response[f++] = a[i].toString()+","+b[j].toString()+","+c[k].toString()+","+d[m].toString();
}
}
}
}
but for different number of arrays, I don't have any idea.