共用方式為


Types and Namespaces 

The following guidelines help you organize your types and namespaces so that they are straightforward to find and use.

Avoid very deep namespace hierarchies. Such hierarchies are difficult to browse as the user has to backtrack often.

Avoid having too many namespaces.

Types that are used in the same scenarios should be in the same namespaces when possible. Users should not have to import many namespaces to develop common scenarios.

Avoid having types designed for advanced scenarios in the same namespace as types intended for common programming tasks.

In general, you should place advanced types in a namespace within the general namespace, and use Advanced as last identifier in the name. For example, the commonly used types related to XML serialization are in the System.Xml.Serialization namespace and the advanced types are in the System.Xml.Serialization.Advanced namespace.

Do not define types without specifying their namespaces.

Types that are not assigned a namespace are placed in the global namespace. Because they are not in a feature-specific namespace, types in the global namespace are difficult to find using development tools. Additionally, name collisions in the global namespace cannot be resolved. For more information, see Names of Namespaces.

Portions Copyright 2005 Microsoft Corporation. All rights reserved.

Portions Copyright Addison-Wesley Corporation. All rights reserved.

For more information on design guidelines, see the "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" book by Krzysztof Cwalina and Brad Abrams, published by Addison-Wesley, 2005.

See Also

Other Resources

Type Design Guidelines
Design Guidelines for Developing Class Libraries