简体   繁体   English

程序集和命名空间

[英]Assemblies and Namespace

Does everything in a single namespace compile into its own assembly?单个命名空间中的所有内容都编译成自己的程序集吗?

No.不。

You can have several namespaces in an assembly, and you can use the same namespace in different assemblies.一个程序集中可以有多个命名空间,并且可以在不同的程序集中使用相同的命名空间。

No, you can have multiple namespaces within an assembly.不,您可以在一个程序集中拥有多个命名空间。 In VS terms, you can think of an assembly as a project.在 VS 术语中,您可以将程序集视为一个项目。 Each project within a solution, gets compiled into it's own assembly.解决方案中的每个项目都被编译成它自己的程序集。 Within an assembly though, you can have multiple namespaces.但是,在一个程序集中,您可以有多个命名空间。

Assemblies and namespaces have nothing to do with each other except that there's a generally used convention that the full names of classes in an assembly will match the assembly name (in some way).程序集和命名空间彼此无关,只是有一个普遍使用的约定,即程序集中的类的全名将匹配程序集名称(以某种方式)。

It's strictly a naming convention - as Guffa said , assemblies can define classes for more than one namespace and the classes that exist in a namespace can come from more than one assembly.这是一种严格的命名约定——正如Guffa 所说,程序集可以为多个命名空间定义类,并且命名空间中存在的类可以来自多个程序集。

Classes are organized in Namespaces just to keep a naming separation and organization.类在命名空间中组织只是为了保持命名分离和组织。 Think of namespaces as "folders" that contain one or more classes, and that might be defined in one or more assemblies (DLLs).将命名空间视为包含一个或多个类的“文件夹”,并且可能在一个或多个程序集 (DLL) 中定义。

more info: https://stackoverflow.com/a/20056937/579381更多信息: https://stackoverflow.com/a/20056937/579381

If you're asking if each namespace results in a seperate assembly, then no.如果您询问每个命名空间是否导致单独的程序集,那么没有。 One assembly can contain multiple namespaces.一个程序集可以包含多个命名空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 常量,WebServices,命名空间和共享程序集 - Constants, WebServices, Namespace, & Shared Assemblies RawRabbit的命名空间和程序集是什么? - What are the proper namespace and assemblies for RawRabbit? 在2个.NET程序集中使用相同名称和命名空间的类型 - Use types of same name & namespace in 2 .NET assemblies 在两个引用的程序集中出现的引用特定名称空间 - Reference Particular Namespace that appears in two referenced Assemblies 更改完整的项目名称空间,程序集,文件夹和引用 - Change complete project namespace, assemblies, folders and references 在多个程序集中使用相同的名称空间是一个好习惯吗? - Same namespace in multiple assemblies is a good practice? 过滤名称空间中的所有程序集(当前程序集除外) - Filter all assemblies in namespace except for current one 在两个不同的程序集中,两个具有相同名称的类可以位于相同的名称空间中吗? - Can two classes with the same name be in the same namespace across two different assemblies? CLR如何在运行时区分不同程序集中具有相同名称但没有名称空间的类? - How does CLR differentiate classes with the same name but without namespace in different assemblies at runtime? 当两个程序集具有相同的命名空间时,如何解决“无法隐式转换”错误? - How to solve 'Cannot implicitly convert' error when two assemblies have the same namespace?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM