.NET namespaces

前端 未结 9 2270
面向向阳花
面向向阳花 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:27

    Yep, in .NET namespace doesn't depend on file system or anything else. It's a great advantage in my opinion. For example you can split your code across different assemblies which allows flexible distribution.

    When working in Visual Studio, IDE tends to introduce new namespace when you add new folder to project tree.

    Here is a useful link from MSDN:

    Namespace Naming Guidelines

    The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design as follows.
    CompanyName.TechnologyName[.Feature][.Design]

    Of course you can use namespaces in the way you find more suitable. However if you going to share your code, I would recommend to go along with accepted standards.

    EDIT:

    I highly recommend to any .net developer to get a copy of Framework design guidelines This book will help you to understand how and why .NET is designed.

提交回复
热议问题