更新:2007 年 11 月
错误消息
成员“name”重写“method”。在运行时有多个重写候选项。将调用哪个方法取决于具体的实现。
有些方法参数的唯一区别在于是 ref 还是 out,对于这些参数,无法在运行时加以区分。
避免此警告
- 为其中一个方法提供不同的名称或参数数目。
示例
下面的代码将生成 CS1957:
// cs1957.cs
class Base<T, S>
{
public virtual string Test(out T x) // CS1957
{
x = default(T);
return "Base.Test";
}
public virtual void Test(ref S x) { }
}
class Derived : Base<int, int>
{
public override string Test(out int x)
{
x = 0;
return "Derived.Test";
}
static int Main()
{
int x;
if (new Derived().Test(out x) == "Derived.Test")
return 0;
return 1;
}
}