namespace and use keyword [closed]
why use of namespace and use keyword and declaration of namespace
Namespaces are used for organizing the types in the code in a logical manner. Imagine the Base Class Library itself, with its many thousands of types, without namespaces. It is simply a tool for making code more structured, much like the ability to create directories in the file system helps you organize your files.
Now, since the full name of a type is the namespace and type name, these may become fairly long. In order to make this easier on you as a developer, you can tell the compiler that you are using types from certain namespaces in a code file with using
(or Imports
in VB.NET) directives, and then you don't need to use the full name in that file. It simply tells the compiler where to go look for any type that is not entered using the full name in the code.
精彩评论