Namespaces and class libraries

Source: Internet
Author: User
Tags custom name


A namespace (namespace) can be thought of as a "container" for a class, which can contain multiple classes, and a generic reference method is to use a using statement at the beginning of the source code. Namespaces can be nested,

Declaring a method: the outermost namespace inside a layer namespace. Class name custom name = new outermost namespace inner layer namespace. Class name ();

class Library is equivalent to an assembly --in order to improve the efficiency of software development, people have applied the modularization principle of software engineering extensively, reused existing modules, developed some new modules, and finally assembled the old and new modules.

How to build a class library:

(1) Right click on the solution and click "New Project ..." as shown.

(2) Select the class library, give the class library a name, choose a good save location, click OK

(3) After successful establishment, write the required method in the class library, then refer to--1, add Class Library 2 in the reference, and write the using statement in the code.

The methods of the area classification library items, assemblies, namespaces:

(1) After each class library project is compiled, an assembly is generated

(2) You can have more than one class in a class library project that can belong to a different namespace

(3) Different class library items can define the same namespace

In general, a "namespace" is a logical concept, and its physical carrier is "Assembly", which is embodied as a "DLL" (or EXE) file. In Visual Studio, you can build an assembly by creating a project of type class library. An assembly can have more than one namespace, and a namespace can be distributed across multiple assemblies.

Namespaces and class libraries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.