Can you explain this edge case involving the C# 'using' keyword with namespace declarations and members?
<p>Consider the following short code snippet.</p>

<pre><code>namespace B
{
    public class Foo
    {
        public string Text
        {
            get { return GetType().FullName; }
        }
    }
}

namespace A.B
{
    public class Foo
    {
        public string Text
        {
            get { return GetType().FullName; }
        }
    }
}
</code></pre>

<p>Get familiar with <strong>example #1</strong> first.</p>

<pre><code>using B;

namespace A.C
{
    public static class Program
    {
        public static void Main()
        {
            Console.WriteLine(new Foo().Text);
        }
    }
}
</code></pre>

<p>Now consider <strong>example #2</strong>.</p>

<pre><code>namespace A.C
{
    using B; // Notice the placement here.

    public static class Program
    {
        public static void Main()
        {
            Console.WriteLine(new Foo().Text);
        }
    }
}
</code></pre>

<p>There is nothing terribly peculiar about example #1. However, things get interesting with example #2. It is imperative that you pay close attention to all identifiers used in the examples. As a fun exercise try to guess what happens without plugging this into the compiler. I will not reveal the answer here because 1) it is easy enough to try yourself and 2) I do not want to ruin the fun.</p>

<p>Will the program:</p>

<ul>
<li>not compile</li>
<li>display B.Foo</li>
<li>display A.B.Foo </li>
</ul>

<p><strong>The question...Where in the C# specification is this behavior described?</strong></p>

<p>I did take a look at section 3.7 in the C# 4.0 specification and especially bullet #2, but I do not think that explains the behavior. If anything it almost makes me think the compiler is behaving contradictory to the specification.</p>
