In C#, what's the difference between A::B
and A.B
? The only difference I've noticed is that only ::
can be used with global
, but other than that, what's the difference? Why do they both exist?
with :: you can do things like...
extern alias X;
extern alias Y;
class Test
{
X::N.A a;
X::N.B b1;
Y::N.B b2;
Y::N.C c;
}
and there are times when . is ambiguous so :: is needed. here's the example from the C# language spec
namespace N
{
public class A {}
public class B {}
}
namespace N
{
using A = System.IO;
class X
{
A.Stream s1; // Error, A is ambiguous
A::Stream s2; // Ok
}
}