C # Getting Started concept-solutions, projects, assemblies, namespaces

Source: Internet
Author: User
It is easy for beginners to confuse these concepts. Let's talk. Project(project), in layman's parlance, a project can be a software that you develop. Under. NET, a project can behave in a variety of types, such as console applications, Windows applications, class libraries (class library), Web applications, Web Service,windows controls, and so on. If compiled, the application will be compiled as an. exe file from the extension, and the remainder will be compiled as a. dll file. Since it is an. exe file, it indicates that it can be executed, in a program that has a main program entry point, the method Main (). class libraries, Windows controls, and so on, do not have this entry point, so they cannot be executed directly, and only provide some functionality to call to other projects.

In Visual Studio.NET, you can create a new project by selecting "New" a "project" from the "File" menu. For example, to create a console application. Note that at this point, Visual Studio, in addition to setting up a console project, also belongs to a solution (Solution). What is the use of this solution. If you only need to develop a project for Hello World, the solution is naturally useless. However, a slightly more complex software, all need a lot of modules to compose, in order to embody the hierarchical relationship between each other, conducive to the reuse of programs, often require multiple projects, each project to achieve different functions, and finally the combination of these projects, formed a complete solution. Figuratively speaking, the solution is a container, in this container, divided into layers, a lot of lattice, used to store different items. A solution is a relationship that is greater than or equal to a project. After the solution is established, a file with the. sln extension is established.

To add a project to the solution, you can no longer use the "new" method, but instead select "Add Project" from the "File" menu. The item that you add can be a new project or a project that already exists.

The assembly is called Assembly. The concept of academic I do not want to mention, in layman's terms, a project is also an assembly. From a design standpoint, it can also be viewed as a complete module (modular), or as a package (Package). Therefore, an assembly can also be embodied as a DLL file, or EXE file. How to divide the assembly is also great article, but beginners do not consider it for the time being.

namespaces (namespace) are concepts in C + +. It was introduced primarily to avoid collisions of the same object names that might exist in a project. There is no special requirement for the definition of this namespace. But basically, in order 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, in foreign names, you can also add middle name. Then the name for Yong, because the surname is different also separate, or call Zhang Yong, or call Zhao. Of course, people's surnames are mostly repetitive, so when we name namespaces, we can be as complicated as possible.

There are many beginners who often interpret a project as a namespace. In fact, there is no absolute connection between the two, in the project we can also define a lot of different namespaces. But for users to be easy to use, it is best to have a single project whose namespaces are best in one hierarchy. In Visual Studio, we can create a new folder in the project, by default, the namespace of the object under that folder, which should be the project's namespace. Folder name. Of course, we can also modify it in the namespace.

The namespace and assembly name can be set in Visual Studio.

Assembly name is the assembly name and, if compiled, the file name of the project. The default namespace, for that same namespace. When developing software, we should develop good habits and set up new projects. Once the default Namespace is set, the newly created object, whose namespace is the set value. As for the assembly name, if it is a DLL file, it is recommended that the name preferably be the same as the default namespace.

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.