Organization of single projects C #

I am reorganizing my source files into one solution with one project due to various reasons:

This leaves me with many namespaces that are split into multiple files. I still use this convention: given the namespace, the Company.Project.Afiles are named A.f1.cs, A.f2.csetc., and the namespace is Company.Project.Bdivided into B.f1.cs, B.f2.csetc.

Given one design limitation, are there better ways to organize multiple files in multiple namespaces?

+5
source share
3 answers

Yes - use folders.

If you create a folder inside the project, new classes in this folder will automatically use the folder name as the basis for the namespace.

For example, if you have a project with the default namespace "Company.Project" and the folder "Foo" containing "Bar.cs", you will get:

using System; // Etc

namespace Company.Project.Foo
{
    class Bar
    {
    }
}
+11
source

So the solution is right here. These are folders. But it is sometimes difficult. First of all, it is a good idea to have one file for each class. If you pack several classes into one file, you will have problems finding them over time.

-, - , , " → ", . ! , .

messing. , , . , , MyClass MyFolder, , MyApp.MyFolder, - .

, , - , .

+2

100% .

, , , .

+1

All Articles