Understanding VB.NET Namespaces

A Namespace in .Net Framework is a set of classes. While creating a web application you may use many classes. .Net Framework, itself contains over 3,500 classes. Therefore it is difficult to find and use the class that you want. Moreover, it would be sheer wastage of time to search a class from 3,500 odd classes. To make you work easier, .Net Framework has Namespaces.

A Namespace consists of a set of classes that are related to each other. This will considerably reduce your search for a class or functionality. The Namespace in .Net Framework is sometimes further classified into a hierarchical structure. For example a Namespace can contain another Namespace that will further include classes. A class in .Net Framework cannot belong to multiple Namespaces. One class should belong to only one Namespace.

All the classes in .Net Framework are connected to System Namespace. For example, System.Data contains classes that accesses data stored in a database, System.Xml contains classes that are used to read and write XML documents, and System.Windows.Forms consists of classes for drawing windows on the screen. While writing code for the applications you do not have to write classes with System Namespace. .Net Framework automatically creates a shorthand version of all the classes.

Apart from the default Namespaces, .Net Framework allows you to create your own Namespaces that will hold certain classes. Namespaces are defined by binding the Class…End Class definition in a Namespace…End Namespace definition. By default, classes created in Visual Basic.NET (VB.NET) are automatically assigned to a root Namespace. If you are developing web application using Visual Studio.NET, then it automatically names this root Namespace based on the project name.

Thus, you can group your code in to discrete logical units using Namespaces. Visual Basic .NET (VB.NET) also allows you to group your code into logical units in assemblies. Therefore you can group your code in two ways, first through assemblies. Through assemblies you can establish security, version, reference, and deployment boundaries. Second, by grouping classes into Namespaces, you can create a hierarchy in which it's easy to identify classes by their fully qualified names. These two methods of organizing code complement each other, and you can use both of them in your own Visual Basic .NET development.

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.