I have been trying to get my head around this but it hasn't been working:
I've gotten this function from http://fir3pho3nixx.blogspot.com/2011/01/recursion-cross-product-of-multiple.html where it returns a list but I can't seem to read the values within each object in the list.
Here is the function in question:
private static List<object> GetCrossProduct(object[][] arrays)
{
var results = new List<object>();
GetCrossProduct(results, arrays, 0, new object[arrays.Length]);
return results;
}
private static void GetCrossProduct(ICollection<object> results, object[][] arrays, int depth, object[] current)
{
for (var i = 0; i < arrays[depth].Length; i++)
{
current[depth] = arrays[depth][i];
if (depth < arrays.Length - 1)
GetCrossProduct(results, arrays, depth + 1, current);
else
results.Add(current.ToList());
}
}
new List<object>()currenton the recursive call? looks like it should hold all elements ofarray[depth], isn't it?