C# : Classes into Folders
When you create a folder in the Visual C# project it normally creates a namespace for items created in that folder. You need to add a using blah.foldername
statement to the c# file where you are trying to use the items from the folder, or you can edit the file in the folder to use namespace blah
instead of namespace blah.folder
.
Visual Studio mimics your project's hierarchy on the hard drive. When you add a solution folder within Visual Studio, it creates a real folder under your project directory. Any new projects or source files you add to the solution folder in Visual Studio will default to that directory. Also, and this gets to the heart of your question, when you add a C# file, i.e., class, to the solution folder, Visual Studio places it in a sub-namespace of your project.
For example, if your project is named MyProject, the default namespace will be MyProject. If you add a solution folder to MyProject called MyFolder, any new files, i.e., classes added to that folder from within Visual Studio will have a default namespace of MyProject.MyFolder. Thus, in order for classes in the MyProject namespace to reference classes in the MyProject.MyFolder namespace, you need to either fully qualify the class name, e.g., MyProject.MyFolder.MyClass or include a using MyProject.MyFolder;
statement at the top of file where the class is used.
If you are asking about solution folders, they don't translate to the resulting code. They are merely a way to organize your projects.
If you are creating folders in your project to separate code files, then traditionally we would have the namespace represent the hierarchical structure of the solution/project.
Then you just include the namespaces as you normally would.
Does this answer your question?