Eric Yin
Eric Yin

Reputation: 8973

How to access root Class when there's a duplicate name?

Check this simple sample:

public class Someone{       // [the:A]
}

public class Another{
    public class Someone{   // [the:B]
    }

    public class DoSomething{
        **how can I access Someone in root, which is [the:A]**?
    }
}

Upvotes: 0

Views: 146

Answers (1)

Dai
Dai

Reputation: 155065

Use the "global::" keyword, or use a using; statement at the top.

global::YourNamespace.Someone

or, in your using statements:

using SomeoneRoot = YourNamespace.Someone;

and in the event that there's an ambiguation in your namespaces, the global:: keyword can be used there too:

using SomeoneRoot = global::YourNamespace.Someone;

Upvotes: 6

Related Questions