Matt,
It is not unambiguous, and it is actually disallowed. You can not have
a class in a namespace with the same name as the namespace explicitly
because of this. What if you had a nested type in class C? The compiler
would have to guess without knowing what C is, and I wouldn't put my trust
in any compiler that did that.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"Matt Mastracci" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> It seems like the C# compile can't resolve the difference between a
> namespace and a class in a situation that is clearly unambiguous. Note
> that it sees the namespace "C" before the class "C". I believe it
> should see the class "C" first.
>
> test1.cs:
> =============
>
> using System;
> using A.C;
>
> namespace A.B
> {
> public class D
> {
> D() { C c = new C(); }
> }
> }
>
> test2.cs:
> =============
>
> using System;
>
> namespace A.C
> {
> public class C
> {
> int X;
> }
> }
>
> =============
>
> C:\>csc /target:library test1.cs test2.cs
> Microsoft (R) Visual C# .NET Compiler version 7.00.9466
> for Microsoft (R) .NET Framework version 1.0.3705
> Copyright (C) Microsoft Corporation 2001. All rights reserved.
>
> test1.cs(8,9): error CS0118: 'A.C' denotes a 'namespace' where a 'class'
was
> expected
>