K
Kyle Blaney
Suppose I have the following in file1.cs (all code is compacted to
reduce the number of lines):
namespace B {
namespace C {
class D {
public static void Print() {
System.Console.WriteLine( "B.C.D.Print" );
}
}
}
namespace E {
class D {
public static void Print() {
System.Console.WriteLine( "B.D.E.Print" );
}
}
}
}
Suppose I have the following in file2.cs:
using B.C;
using B.E;
namespace A {
class A1
{
public void Main()
{
D.Print();
}
}
}
As expected, the compiler complains about the call to D.Print in
file2.cs with the error "D is an ambiguous reference". I can resolve
the reference by changing the method call to "B.C.D.Print()" or
"B.D.E.Print()". I want to resolve the reference by adding a "using
B" directive and changing the method call to "C.D.Print()". However,
when I try that I get the error "The type or namespace name 'C' could
not be found."
Why can't I resolve the ambiguity the way I want?
reduce the number of lines):
namespace B {
namespace C {
class D {
public static void Print() {
System.Console.WriteLine( "B.C.D.Print" );
}
}
}
namespace E {
class D {
public static void Print() {
System.Console.WriteLine( "B.D.E.Print" );
}
}
}
}
Suppose I have the following in file2.cs:
using B.C;
using B.E;
namespace A {
class A1
{
public void Main()
{
D.Print();
}
}
}
As expected, the compiler complains about the call to D.Print in
file2.cs with the error "D is an ambiguous reference". I can resolve
the reference by changing the method call to "B.C.D.Print()" or
"B.D.E.Print()". I want to resolve the reference by adding a "using
B" directive and changing the method call to "C.D.Print()". However,
when I try that I get the error "The type or namespace name 'C' could
not be found."
Why can't I resolve the ambiguity the way I want?