Omer van Kloeten's .NET Zen

Programming is life, the rest is mere details

News

Note: This blog has moved to omervk.wordpress.com.

Omer van Kloeten's Facebook profile

Omer has been professionally developing applications over the past 8 years, both at the IDF’s IT corps and later at the Sela Technology Center, but has had the programming bug ever since he can remember himself.
As a senior developer at NuConomy, a leading web analytics and advertising startup, he leads a wide range of technologies for its flagship products.

Get Firefox


powered by Dapper 

.NET Resources

Articles :: CodeDom

Articles :: nGineer

Culture

Projects

A C# Riddle, Try #2

The code below compiles (sorry about that again) and is actually the code problem I originally wanted to post. Now play the compiler - which is Bar's base class and why:

namespace NS
{
    namespace NS
    {
        class Cls // Candidate #1
        {
        }
    }

    class Cls // Candidate #2
    {
    }

    namespace Foo
    {
        class Bar : NS.Cls // Who am I?
        {
        }
    }
}

For extra credit, how do I force the compiler to choose the other one?

[Update: Good going, everyone! Candidate #2 is indeed the one used. To use candidate #1, you must either apply the 'global::' prefix or explicitly use the class's full name.]

Posted: Mar 09 2007, 01:07 PM by Omer van Kloeten | with 7 comment(s)
Filed under:

Comments

No Comments