This is the 26th day of my participation in the August More Text Challenge

The assembly

An assembly is a collection of one or more type definition files and resource files.

Assemblies are the main building blocks of.NET framework applications. All managed types and resources are contained within an assembly and marked as accessible only from within that assembly or from code in another assembly.

When working on a project, programmers can use classes or types from existing libraries, as well as create their own. These library files, usually with a.dll extension, are called assemblies.

Using existing assemblies or creating and using your own is an integral part of large-scale programming.

Of all the files that an assembly contains, there is a file that holds a list of assembly information that contains the names of files that are part of the assembly, the version of the assembly, the language culture, the publisher, the shared export types, and all the files that make up the assembly.


The namespace

To solve naming conflicts between assemblies and types, C# provides a mechanism for organizing types using namespaces.

A namespace is a compilation unit used to organize and reuse code, and is a group of classes and types that share namespace names. Each namespace has a unique name that is different from the other namespaces.

The syntax for declaring a namespace is as follows:

namespaceNamespace name {namespace member}Copy the code

The members of a namespace are the classes and types contained in the namespace. The declarations of all classes and types contained in the namespace must be enclosed in braces within the namespace declaration.

A namespace name is a string that can contain a ‘. ‘character, which can be preceded by a class or type name for information separation and hierarchy.

Namespace naming rules:

  1. A namespace name can be any valid identifier;
  2. You typically start a namespace name with the company name followed by the technology name;
  3. Do not name a namespace the same as a class or type.

A nested declaration of a namespace has two syntactic forms:

/ / form 1
namespaceNamespace name 1 {namespace1A member of thenamespaceNamespace name 2{namespace2Members of}}2 / / form
namespaceNamespace name 1 {namespace1A member of the}namespaceNamespace name 1. namespace name 2 {namespace2A member of the}Copy the code

Using

  1. The using directive introduces the namespace:
using System;
using System.Collections;
Copy the code
  1. Using static directive: Specifies a type whose static members can be accessed without specifying a type name
using static System.Math; // Use system.math.pi directly

double pai = PI;
Copy the code
  1. names
using Project = PC.MyCompany.Project;
Copy the code
  1. Using statement: Binds instances to code
using (Book b1 = new Book("aaa".15.0 f),
            b2= new Font("bbb".20.0 f))
{
    // Use b1 and b2
}
Copy the code

At the end of the code segment, Dispose method of B1 and B2 is automatically called to release the instance.