我有这两个错误:
“System.Array”不包含“Aggregate”的定义,并且找不到接受“System.Array”类型的第一个参数的扩展方法“Aggregate”(您是否缺少 using 指令或程序集引用?)
“System.Collections.Generic.IEnumerable<object[]>”不包含“ToArray”的定义,并且没有扩展方法“ToArray”接受“System.Collections.Generic.IEnumerable<object[]>”类型的第一个参数可以找到(您是否缺少 using 指令或程序集引用?)
这是我的代码:
/*
* Get all the possible permutations
*/
public static IEnumerable<object[]> CartesianProduct(params object[][] inputs)
{
//ERROR: Function Aggregate is not recognized
return inputs.Aggregate(
(IEnumerable<object[]>)new object[][] { new object[0] },
(soFar, input) =>
from prevProductItem in soFar
from item in input
select prevProductItem.Concat(new object[] { item }).ToArray());
}
public void test()
{
//Get all the posible permutations between parents values.
var cartesianProduct = CartesianProduct(parentsValues);
object[][] producto = cartesianProduct.ToArray();
//ERROR: Function ToArray is not recognized
}