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