Practical Examples of Namespaces in VB.NET 2005 - Inheriting a class from a root namespace (or assembly): example
(Page 5 of 6 )
This section is based on the explanation in the previous two sections. Let us create a solution with the name "SampleInheritance" and add a simple class "First" as follows:
PublicClass First
Private m_x As Integer
Private m_y As Integer
Public Sub New(ByVal a As Integer, ByVal b As Integer)
m_x = a
m_y = b
End Sub
Public Property X() As Integer
Get
Return m_x
End Get
Set(ByVal value As Integer)
m_x = value
End Set
End Property
Public Property Y() As Integer
Get
Return m_y
End Get
Set(ByVal value As Integer)
m_y = value
End Set
End Property
EndClass
Please be aware that the above doesn't belong to any namespace; instead, it belongs to the root namespace (or the assembly). Let us add one more class "First" as follows:
NamespaceNamespace1
Public Class First
Private m_a As Integer
Private m_b As Integer
Public Sub New(ByVal x As Integer, ByVal y As Integer)
m_a = x
m_b = y
End Sub
Public Property A() As Integer
Get
Return m_a
End Get
Set(ByVal value As Integer)
m_a = value
End Set
End Property
Public Property B() As Integer
Get
Return m_b
End Get
Set(ByVal value As Integer)
m_b = value
End Set
End Property
End Class
EndNamespace
The above is another class with the same name "First" with a different set of properties. Observe that it is encapsulated within a new namespace, "Namespace1." The next section will show you how to inherit each of them according to your needs.
Next: Inheriting a class from root namespace (or assembly): example continued >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee