編譯器警告 (層級 1) CS1957
更新: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;
}
}