VB.NET namespaces organize code by grouping related type names and reducing name collisions. Namespaces are commonly used to specify which .NET framework libraries are needed for a program. Code can be organized into hierarchies with namespaces nested within other namespaces. For example, the Button class is contained within the System.Windows.Forms namespace, which is part of the larger System namespace that contains many commonly used namespaces like System.IO and System.Collections.
1 of 7
Downloaded 31 times
More Related Content
VB.NET:An introduction to Namespaces in .NET framework
2. ? The most common way that VB.NET namespaces
are used by most programmers is to tell the
compiler which .NET Framework libraries are
needed for a particular program.
? .NET codes can be organized using namespaces.
? Namespaces organize the objects defined in an
assembly.
? Namespaces are not replacements for
assemblies, but a second organizational method
that complete assemblies.
? Namespaces are a way of grouping type names
and reduce the chance of name collisions.
3. For example a button type is contained in
system.windows.forms namespace. This is
actually shorthand for the situation shown in
figure below:
Button class
Form Namespace
Window Namespace
System Namespace
4. ? System is the basic namespace used by every
.NET code. There are lots of namespace user
the system namespace. For example,
? System.IO,
? System.Net,
? System.Collections,
? System.Threading,
? System.Data,
? Ststem.Drawing, etc.
5. ? VB.NET Code:
Namespace College
Namespace students
Imports System
Class Addstudents
Public Function S_Method()
Console.WriteLine("Adding Students to college using S_Method!")
End Function
End Class
End Namespace
End Namespace
6. Let's look how we can use the namespaces in our code.
I'm going to create a program to use the namespaces.
VB.NET Code:
Imports System
Class HelloWorld
Public Sub Main()
Dim AddStd As Student.AddStudent= New AddStudent AddStd.S_Method()
End Sub
End Class