In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use C # namespaces and assemblies". In daily operations, I believe many people have doubts about how to use C # namespaces and assemblies. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about how to use C # namespaces and assemblies. Next, please follow the editor to study!
Except for relying on several system-provided classes (such as System.Console), the programs introduced so far are independent. But it is more common that the actual application consists of several different parts, each compiled separately. For example, an enterprise application may rely on several different components, including some internally developed components and some purchased from independent software vendors.
C # namespaces and assemblies help develop component-based systems. Namespaces provide a logical organization. Namespaces are used as both "internal" and "external" organizational systems for programs (a way to expose program elements to other programs).
Assemblies are used for physical packaging and deployment. Assemblies can contain types, executable code that implements those types, and references to other assemblies.
There are two main types of assemblies: applications and libraries. An application has a main entry point, which usually has a .exe file extension, while a library does not have a main entry point and usually has a .dll file extension.
To illustrate the use of the C # namespace and assembly, this section again takes the "hello, world" program introduced earlier as an example and divides it into two parts: a class library that provides messages and a console application that displays messages.
This class library contains only one class named HelloMessage. Example
/ / HelloLibrary.cs namespace Microsoft.CSharp.Introduction {public class HelloMessage {public string Message {get {return "hello, world";}}
Shows the HelloMessage class in the namespace named Microsoft.CSharp.Introduction. The HelloMessage class provides a read-only property named Message. Namespaces can be nested, while declaring
Namespace Microsoft.CSharp.Introduction {...}
Is just a shorthand form of several layers of namespace nesting. If it is not simplified, it should be declared like this:
Namespace Microsoft {namespace CSharp {namespace Introduction {...}
The next step in componentizing "hello, world" is to write a console application that uses the HelloMessage class. You can use the fully qualified name Microsoft.CSharp.Introduction.HelloMessage of this class, but it is too long to use. A more convenient way is to use the using Namespace directive so that you do not have to qualify names when using all types in the corresponding namespace.
At this point, the study on "how to use C# namespaces and assemblies" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.