C # Return to the initial starting point-solution, project, assembly, and namespace,

Source: Internet
Author: User

C # Return to the initial starting point-solution, project, assembly, and namespace,

 

C # Return to the initial starting point-solution, project, assembly, and namespace
-- Percy

Beginners can easily confuse these concepts. Let's talk about projects first. In general, a Project can be a software you develop. In. Net, a project can be displayed in various types, such as console applications, Windows applications, Class libraries, Web applications, Web Services, and Windows controls. After compilation and translation, the application will be compiled into an. EXE file, and the rest will be compiled into a. dll file. Both the. exe file indicates that it can be executed, as shown in the program. These applications all have a Main program entry point, that is, the method Main (). Class Libraries and Windows controls do not have this entry point, so they cannot be directly executed. Instead, they only provide some functions for other projects to call.

 

In Visual Studio. Net, you can select "new" and "Project" from the "File" menu to create a new Project. For example, create a console application. Note that in addition to creating a console project, Visual Studio also provides a Solution ). What is the purpose of this solution? If you only need to develop a Hello World project, the solution will naturally be useless. However, a slightly more complex software requires many modules. To reflect the hierarchical relationship between each other and facilitate program reuse, multiple projects are often required, each project implements different functions. Finally, these project groups are combined to form a complete solution. In an image, the solution is a container, which is divided into multiple layers and multiple cells to store different projects. The relationship between a solution and a project is greater than or equal. After the solution is created, a file with the. sln extension will be created.

Add a Project to the solution. You cannot use the "new" method. Instead, select "Add Project" in the "File" menu ". The added project can be a new project or an existing project.

Assembly is called Assembly. I don't want to mention the academic concept. In general, a project is also an assembly. From the design perspective, it can also be regarded as a complete Module or Package ). Therefore, an assembly can also be reflected as a dll file or exe file. There are many articles about how to divide an assembly, but beginners do not need to consider it for the moment.

Namespace is a concept in C ++. It is introduced to avoid conflicts of the same object names in a project. This namespace has no special requirements. But basically, to ensure its uniqueness, it is best to use the uri format, such as BruceZhang.com. This namespace is a bit like the last name in our name, and then the name of each object is the name in the name. If there are duplicates, you can add the middle name to foreign names. The names are brave. The names are separated by different surnames, either Zhang Yong or Zhao Yong. Of course, most people have repeated surnames, so we try to be as complicated as possible when naming a namespace.

Many beginners often regard a project as a namespace. In fact, there is no absolute relationship between the two. In the project, we can also define many different namespaces. However, for ease of use, it is recommended that the namespace of a project be an integrated hierarchy. In Visual Studio, we can create a new folder in the project. By default, the namespace of the objects in the folder should be "project namespace. Folder name ". Of course, we can also modify it in namespace.

You can set the namespace and set name in Visual Studio. Right-click the project name and select properties. The following dialog box is displayed:


Copyright Disclaimer: This article is an original article by the blogger. You are welcome to repost it. Please indicate the source for reprinting.

 

Related Article

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.