I ask this question because I'm getting a compilation error in my solution: 'GiftCard' is a 'namespace' but is used like a 'type'
I tried adding a using directive like: using GiftCard.Data.Entity;
which is the correct namespace where GiftCard is found, but the error does not go away. When I add the fully qualified name in my code, i.e. GiftCard.Data.Entity.GiftCard
...then the error goes away, and code compiles.
But I'm wondering why the using directive does not work. I don't want to clutter my code with the fully qualified name every time I need to use the type. Somehow the error message is saying that I have GiftCard defined as a namespace somewhere. So how can I find all the namespaces in my solution so that I know where it is defined because I need to either remove or rename the GiftCard namespace.
Your have a different question and a different problem.
The Problem
The Framework Design Guidelines says Do not use the same name for a namespace and a type in that namespace
.
For example, do not use Debug as a namespace name and then also provide a class named Debug in the same namespace. Several compilers require such types to be fully qualified.
That is:
namespace Debug
{
public class Debug{ … }
}
OR
namespace MyContainers.List
{
public class List { … }
}
Why is this badness? Do not name a class the same as its namespace
Answer for the Question
View -> Object Browser (Shortcut : Ctrl+Alt+J)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With