I now feel good at C # is to know, C # basic syntax, C # 's new features, C # can do!
I feel that regardless of how, namespace is very critical, can be said not only for C #, but the whole. NET is made up of namespace, so I read the basic syntax of C #, I went straight to namespace, write down some of their feelings here, I hope to be able to learn from the back of the people have some help.
namespace in the new net environment programming can be said to be ubiquitous, in short, give me the feeling is that the core of MS's new generation of language is namespace, we can through the existing namespace, do what we want to do and willing to do, Of course if you feel that the existing is not enough for your use, you can also use the existing to expand, create your own namespace! (How does it feel like the previous COM and DCOM?) )
Next I'll talk about how to build a namespace!
Defining a namespace first needs to include keywords: namespace
The format is as follows:
Namespace Your_nsname
{
Namespase main content;
}
Oh, I feel like a class or struct as well. But in addition to the form of similar, and indeed in many aspects are not the same, specifically we will slowly talk about! Look down first ...
Within the body of a namespace, you can refer to other namespace! For example:
Namespace your_nsname{
The following refers to system and System.Xml with two namespace;
Using System;
Using System.Xml;
Namespase main content;
}
One thing to note above is that if you want to refer to namespace, then you should refer to it before declaring the other types, which are incorrect:
Namespace your_nsname{
some other content;
Since the reference system and the System.Xml are placed behind other statements, ...
Using System;
Using System.Xml;
}
Another interesting place for namespace is ...
Let's take a look at the following two ways:
Way One,
Namespace N1. N2
{class A {}
Class B {}
}
Way Two,
Namespace N1
{
Namespace N2
{
Class A {}
Class B {}
}
}
In the above-bred way, the second is easy to understand, is to create a namespace N2 in namespace N1, and N2 has two classes (class) A, B! So what's the first kind? In fact, the above two ways of definition are actually identical. namespace can be nested defined, we can use the second way, the hierarchy feel more clear, you can also use the first way, the difference is that in the first way, between N1 and N2 must use the delimiter "." To show the hierarchical relationship between them!
Use it in the following ways:
N1. N2. A
N1. N2. B
The above is C # inside the namespace Foundation (a) content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!