C#: Problem trying to resolve a class when two namespaces are similar
You can use global::
to globally qualify a namespace: global::Foo.Class1
should work,.
You could also alias global::Foo
to make things easier. At the top of your source file, below your using statements, add:
using AliasClass1=global::Foo.Class1;
Now you can use:
AliasClass1 c = new AliasClass1();
// and so on.
Of course, you can use a better name than AliasClass
:-)
In addition to LBushkin's answer, you might be interested in these articles by Eric Lippert :
Do not name a class the same as its namespace, Part One
Do not name a class the same as its namespace, Part Two
Do not name a class the same as its namespace, Part Three
Do not name a class the same as its namespace, Part Four
They are not directly related to your problem, but they give an interesting insight on naming strategies
var x = new global::Foo.Class1();