blob: 1972f45ef21ff444cb200154b01f5c1c47fb92a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// cs0121-3.cs: The call is ambigious between `IInteger.Add (int)' and `IDouble.Add (double)'
// line 28
// (note, this is taken from `13.2.5 Interface member access')
interface IInteger {
void Add(int i);
}
interface IDouble {
void Add(double d);
}
interface INumber: IInteger, IDouble {}
class Number : INumber {
void IDouble.Add (double d)
{
System.Console.WriteLine ("IDouble.Add (double d)");
}
void IInteger.Add (int d)
{
System.Console.WriteLine ("IInteger.Add (int d)");
}
static void Main ()
{
INumber n = new Number ();
n.Add(1); // Error, both Add methods are applicable
n.Add(1.0); // Ok, only IDouble.Add is applicable
((IInteger)n).Add(1); // Ok, only IInteger.Add is a candidate
((IDouble)n).Add(1); // Ok, only IDouble.Add is a candidate
}
}
|