编译以下代码将返回The call is ambiguous between the following methods or properties
错误。由于我无法将 null
显式转换为这些类中的任何一个,因此如何解决它?
static void Main(string[] args)
{
Func(null);
}
void Func(Class1 a)
{
}
void Func(Class2 b)
{
}
最佳答案
Func((Class1)null);
关于c# - 参数为空时如何解决歧义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4044055/