background image

Namespace HelloWorldSample

<< First VB.NET program | Public Class HelloWorld >>
<< First VB.NET program | Public Class HelloWorld >>
System.Console.WriteLine("HelloWorld")
End
Sub
'end of Class Declaration
End
Class
'end of the Class Module
'end of namespace
End Namespace
This is how it goes in your favorite editor `Notepad'


Now let us spend sometime in examining the HelloWorld program to find out what's new
in writing code through any .NET language.

The lines in the program that starts with a `(single quote) are comment entries like in
other programming languages which are excluded in the compilation process. Like VB
the way in which comment entries are represented remains the same in VB.NET.

Namespace HelloWorldSample - The keyword "Namespace" is new to some
programmers who are not familiar with C++.

`Namespace'
­ a keyword in .NET is used to avoid name collisions i.e. For example, you
develop a library which has a class named "File" and you use some other library which
also has a class named "File", in those cases there are chances of name collision. To
avoid this you can give a namespace name for your class, which should be meaningful. It
is always better to follow the syntax (MS Recommended) given below while giving
names for your namespaces

CompanyName.TechnologyName

However the hierarchy can be extended based on the implementation of the classes in the
library.