Practical Examples of Namespaces in VB.NET 2005 - Inheriting a class from a root namespace (or assembly)
(Page 3 of 6 )
This is a bit different from what we examined up to now. If I define a class without specifying any namespace, it generally belongs to a root namespace, which is generally the same as the assembly name itself (or the project name).
To put it simply, if you define classes which do not belong to any namespace, they straight away belong to assembly. It is quite easy to inherit from these types of classes, as we don't need to specify any name for the namespace during inheriting.
But there exists a small trick here to learn. We need to understand the "scope" of access. Even though I will not talk about "scope" in a detailed manner, I shall introduce you to a bit of it. In my upcoming articles, I shall explain in detail.
Every project you create will turn into an assembly at run time. That means, when you hit F5 (or run) to execute the project, it converts all of your code in all of your files into a single file called assembly. The physical and logical name of this assembly would be generally the same name as that of our project name (unless we configure it in a different way). To put it simply, an assembly is physical and a namespace is logical (but both will have the same names). An assembly physically stays in the file system (or at references), but we use namespaces (in our programming) to import/access the content of assembly.
To access any class/namespace within an assembly, we need to start with the name of the assembly of import first. All our classes and namespaces are encapsulated within this assembly (logically accessed with the root namespace name). If we wanted to inherit a class from a class within the same assembly and within the same root namespace, generally we don't need to specify the assembly name (or root namespace name). This is what we did (unknowingly) in the first few sections of my previous article.
The next section will give you some practical understanding of the above theory.
Next: Inheriting a class from a root namespace (or assembly) in practice >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee