<分区>
假设我有一个重载的方法。一种采用返回 uint 的函数,一种采用返回 int 的函数。
static void test1(Func<uint> f)
{
//things
}
static void test1(Func<int> f)
{
// also things
}
现在我试着这样调用它:
test1(Random.FunctionThatReturnsUints);
但是我在编译时得到了一个不明确的调用错误:
Error 4 The call is ambiguous between the following methods or
properties: 'RNG_Comparison.Run.test1(System.Func<int>)' and 'RNG_Comparison.Run.test1
(System.Func<uint>)'
这是怎么回事?重载一个函数的全部意义不是让它根据类型隐含地理解你的意思吗?我的意思是,如果我用返回 BigInt 或其他东西的 func 调用它,也许我可以看到编译器的困惑,但这个看起来很简单。
有谁知道我为什么会收到这个错误?