【发布时间】:2011-04-15 09:14:42
【问题描述】:
我收到以下错误:
error CS0305: Using the generic type
'System.Func<T1,T2,T3,T4,T5,T6,T7,T8,T9,TResult>'
requires '10' type arguments
在这一行:
public static IDoubleArray ApplyFunc(IDoubleArray inputArray1,
IDoubleArray inputArray2,
Func<double, double, double> f) {
System 命名空间中的 Func 定义如下所示:
[TypeForwardedFrom("System.Core, Version=3.5.0.0,
Culture=Neutral,
PublicKeyToken=b77a5c561934e089")]
public delegate TResult
Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
一切看起来都很好,但编译器不这么认为。
有什么办法解决这个问题吗?
谢谢。
编辑:
调用如下所示:
/// <summary>Inverse cumulative distribution function</summary>
/// <param name="p">Probabilities at which to compute the inverse cdf</param>
/// <param name="mu">Scale parameters</param>
public static IDoubleArray Inv(IDoubleArray p, IDoubleArray mu)
{
return ArrayMath.ApplyFunc(Matrix.ConvertToMatrix(p), Matrix.ConvertToMatrix(mu), Inv);
}
【问题讨论】:
-
ApplyFunc 的调用是什么样子的
-
你确定错误信息不是
The best overloaded method match for '...ApplyFunc(IDoubleArray, IDoubleArray, System.Func<double,double,double>)' has some invalid arguments...? -
因为您传递给
ApplyFunc的Inv函数有一个签名=(IDoubleArray, IDoubleArray, IDoubleArray)和ApplyFunc需要(double, double, double)还是我偏离了轨道? -
ApplyFunc 有签名 (IDoubleArray, IDoubleArray, Func
)。还有另一个带有签名的 Inv 函数(双精度、双精度)。但这不是问题。该错误是在 ApplyFunction 定义中生成的,因此调用无关紧要。感谢您的评论。