.NET namespaces

前端 未结 9 2377
面向向阳花
面向向阳花 2020-12-31 18:38

My background is primarily as a Java Developer, but lately I have been doing some work in .NET. So I have been trying to do some simple projects at home to get better at wor

9条回答
  •  温柔的废话
    2020-12-31 19:15

    A VS solution normally contains one or more projects. Thse projects have default namespaces (usually the namespace is just the name of the project). Normally, if you add a folder within the project, all the classes in it will be named as follows:

    DefaultNamespace.FolderName.ClassName

    Of course, you can change the default namespace of the project, and have your classes be named in whatever manner you wish.

    As far as when/how to break stuff into projects, that's a matter of experience and/or preference. However, you should absolutely break stuff into projects within a solution, in order to keep your project organized. If managing too many assemblies becomes cumbersome (as Blair suggested), you can always ILMerge your assemblies into a single assembly. What's great about ILMerge is that even though you end up with just one assembly, all your classes keep their original fully qualified names.

    It's also important to remember that a VS solution has no bearing on code - ie. they do not get built. VS Solutions are nothing but a way to group projects; it's the projects that are built and turned into DLLs.

    Finally, VS let's you add "virtual" folders anywhere in the solution. These folders do not map to a folder in the filesystem, and are just used as another mean to help you organize your projects and other artifacts within the solution.

提交回复
热议问题