编译器警告(等级 2)CS0467
方法“method”和非方法“non-method”之间存在多义性。正在使用方法组。
如果继承的成员具有相同的签名,但来自不同的接口,则会导致多义性错误。
下面的示例会产生 CS0467。
// CS0467.cs
interface IList
{
int Count { get; set; }
}
interface ICounter
{
void Count(int i);
}
interface IListCounter : IList, ICounter {}
class Driver
{
void Test(IListCounter x)
{
// The following line causes the warning. The assignment also
// causes an error because you can't assign a value to a method.
x.Count = 1;
x.Count(3);
// To resolve the warning, you can change the name of the method or
// the property.
// You also can disambiguate by specifying IList or ICounter.
((IList)x).Count = 1;
((ICounter)x).Count(3);
}
static void Main()
{
}
}