I now feel that C # is to know the basic syntax of C #, the new features of C #, and what can C # Do!
I feel that NAMESPACE is critical in any case. It can be said that it is not only for C #, but for the whole. NET is composed of namespaces, so after reading the basic syntax of C #, I went straight to NAMESPACE and wrote some of my feelings here, I hope it will be helpful to those who will study later.
NAMESPACE programming in the new NET environment can be said to be ubiquitous. In short, I feel that the core of the new generation of MS language is NAMESPACE. We can use the existing NAMESPACE, do what we want and are willing to do. Of course, if you feel that you are not enough to use the existing one, you can also use the existing extension to create your own NAMESPACE! (How does it feel like the previous COM and DCOM ?)
Next, let's talk about how to create a NAMESPACE!
To define a NAMESPACE, you must first include the keyword namespace.
The format is as follows:
Namespace Your_nsname
{
// Namespase subject content;
}
Haha, it feels like a Class or Struct. However, apart from their similar forms, they are indeed different in many aspects. We will talk about them later! First, let's look...
Other Namespaces can be referenced in a NAMESPACE entity! For example:
Namespace Your_nsname {
// The following references two namespaces: System and System. Xml;
Using System;
Using System. Xml;
// Namespase subject content;
}
Note that if you want to reference NAMESPACE, you should reference it before declaring other types. The following is an error:
Namespace Your_nsname {
// Other content;
// Because the reference System and System. Xml are placed after other statements, so...
Using System;
Using System. Xml;
}
Another interesting thing about NAMESPACE is...
Let's take a look at the following two methods in pipeline:
Method 1,
Namespace N1.N2
{Class {}
Class B {}
}
Method 2,
Namespace N1
{
Namespace N2
{
Class {}
Class B {}
}
}
In the above improved method, the second one is easy to understand. It is to create another NAMESPACE N2 in NAMESPACE N1, and there are two classes (class) A and B in N2! What about the first one? In fact, the above two methods are exactly the same. NAMESPACE can be defined in nesting mode. We can use the second method to make the hierarchy clearer or use the first method. The difference is that in the first method, the separator ". to indicate the hierarchical relationship between them!
Use the following method when using it:
N1.N2.;
N1.N2. B;