David Rettenbacher
David Rettenbacher

Reputation: 5120

C#: Tests.* namespace hides another namespace

I have 2 namespaces:
Project.Core;
Tests.Project.Core;

In Project.Core there is a Class named "Text". In Tests.Project.Core.TextTests (where I place tests for Text) I also use NUnit which also has a class Text. I thought: "OK, make it fully qualified." and wrote Project.Core.Text.

Now the compiler complains that it can't find Project.Core.Text. This is because the namespace-part "Project.Core" is also found in "Tests. Project.Core" (!) and it doesn't realise that it's a fully qualified name already...

What can I do to make the compiler select the right class?

Upvotes: 0

Views: 141

Answers (1)

Iñaki Elcoro
Iñaki Elcoro

Reputation: 2181

You need to use the global keyword:

var text = new global::Project.Core.Text()

Upvotes: 2

Related Questions