編譯器錯誤 CS0229
更新:2007 年 11 月
錯誤訊息
'member1' 和 'member2' 之間模稜兩可
不同介面的成員擁有相同名稱。如果您想保持相同名稱,便必須限定該名稱。如需詳細資訊,請參閱介面 (C# 程式設計手冊)。
![]() |
---|
在某些案例中,透過 using 別名將明確前置詞提供給識別項,就可以解決這種模稜兩可 (Ambiguity)。 |
範例
下列範例會產生 CS0229:
// CS0229.cs
interface IList
{
int Count
{
get;
set;
}
void Counter();
}
interface Icounter
{
double Count
{
get;
set;
}
}
interface IListCounter : IList , Icounter {}
class MyClass
{
void Test(IListCounter x)
{
x.Count = 1; // CS0229
// Try one of the following lines instead:
// ((IList)x).Count = 1;
// or
// ((Icounter)x).Count = 1;
}
public static void Main() {}
}