Practical Examples of Namespaces in VB.NET 2005 - Inheriting a class from a root namespace (or assembly) in practice
(Page 4 of 6 )
This section proceeds based on the theory explained in the previous section. Let us start from the beginning again. In this scenario, the name of the project (or assembly) is "SampleInheritance." Let us define a class (without any namespace) as follows:
PublicClass First
.
.
.
EndClass
In the case above, without your understanding, it would be treated as something like the following (internally):
PublicClass SampleInheritance.First
.
.
.
EndClass
Now, if you wanted to define a new class by inheriting from the above, you can define it in any of the ways as follows:
PublicClass Second
Inherits First
.
.
.
EndClass
PublicClass Second
Inherits SampleInheritance.First
.
.
.
EndClass
This type of usage or naming would be essential when you have same class names in root namespace and in your own created namespace. To make it simple, if you want to inherit from a class which doesn't belong to any namespace, kindly include the name of the assembly (or project name) to eliminate confusion and to attain better readability.
Finally, if you defined your own namespace as follows:
NamespaceNamespace2
.
.
.
EndNamespace
it would also be treated something like the following (internally):
NamespaceSampleInheritance.Namespace2
.
.
.
EndNamespace
Next: Inheriting a class from a root namespace (or assembly): example >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee