gpt4 book ai didi

C# 命名空间和程序集最佳实践

转载 作者:IT王子 更新时间:2023-10-29 04:21:13 26 4
gpt4 key购买 nike

C#:在将解决方案划分为命名空间和程序集时,是否有任何指南和最佳实践?命名空间通常应该是嵌套的,最底层和最基本的类在顶级命名空间中吗?一个程序集通常应该有一个命名空间吗?在一个命名空间中包含多个程序集或在一个程序集中包含多个命名空间是否存在任何缺陷。多个程序集或非常大的程序集是否有任何编译时间/运行时间惩罚?

最佳答案

C#: are there any guidelines, best practices when it comes to dividing a solution up into name-spaces and assemblies?

有关命名空间的指南,请阅读框架设计指南。

对于程序集:根据定义,程序集是 .NET 中自描述可交付功能的最小独立版本单元。您打算将软件的某些部分彼此独立地发布或版本化吗?那么它们应该在不同的组件中。

Should name spaces normally be nested, with the most low level and fundamental classes in the top level name space?

不一定,不。

namespace 的设计应使用户易于发现和理解这些 namespace 中包含的类型。或许您应该询问您的用户他们的想法。

Should there generally be one name-space to one assembly?

不一定,不。

Are their any pitfalls to having multiple assemblies in one name-space or multiple name-spaces in one assembly.

不特别,不。

Are there any compile time / run time penalties for multiple assemblies or very large assemblies?

我不知道。

关于C# 命名空间和程序集最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8934570/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com