I’m a beginner on C# (I know Java well though) and came to a problem with naming namespaces and classes/interfaces the same.
What won’t work is this:
- Projekt
--> (Interface) Node
--> (Namespace/Folder) Node
-----> (Class): SomethingNode : Node
-----> ...
Because there is an error that the type “Project.Node” and the Namespace “Project.Node” are named the same.
I will explain why I would intentionally like to name those the same: I have many classes who implement the interface “Node”. Those classes should all be in one namespace, so why don’t name them “Node” I thought. The Interface “Node” should be in the project’s root namespace, because it’s used by other classes and I don’t want to e.g. move the interface “Node” to “Project.Node.Node”, because I think it would be silly to allways import “Project.Node” just because I need the interface.
So my question is, how should I resolve this situation? How should I name my classes/namespaces, is there a nice elegant way of doing this, are there any naming conventions for this kind of situation?
You should follow .NET conventions and name your interface
INode. Then classes inside the Node namespace will implement yourINodeinterface.