Ambiguous function/constructor call in C#
Posted
by Ahmed Said
on Stack Overflow
See other posts from Stack Overflow
or by Ahmed Said
Published on 2010-05-19T12:25:28Z
Indexed on
2010/05/19
12:30 UTC
Read the original article
Hit count: 515
c#
|ambiguous-call
The following code causes a compiler error, as it is ambiguous call but the problem if we use object
instead of ArrayList
no error happens and the string
version works fine; Do you have an explanation for that?
class A
{
public A(string x)
{
Console.WriteLine("string");
}
public A(ArrayList x)
{
Console.WriteLine("ArrayList");
}
}
static void Main(string[] args)
{
A o = new A(null);
}
© Stack Overflow or respective owner