|
-
February 23rd, 2009, 12:17 PM
#1
Custom Classes - HowTo access property of parent instance from child instance
How to access a property of the PARENT custom class instance from a CHILD custom class instance.
Simply as a convenience for discussion ... let's assume
A Mammal has teeth
Teeth are an array of Tooth's
From inside one instance of the TOOTH class ...
... how do I get access to a property (Carnivore) in the MAMMAL class?
'-------------------------------------------------------------
Public Class Mammal
Private myTeeth As New Teeth()
Public Sub New()
End Sub
Private pCarnivore As Boolean = False
Public Property Carnivore() As Boolean
Get
Return pCarnivore
End Get
Set(ByVal value As Boolean)
pCarnivore = value
End Set
End Property
End Class
'-------------------------------------------------------------
Public Class Teeth
Private myTooth() As Tooth
Public Sub New()
End Sub
End Class
'-------------------------------------------------------------
Public Class Tooth
Public Sub New()
End Sub
Private pLngth As Integer
Public Property Lngth() As Integer
Get
Return pLngth
End Get
Set(ByVal value As Integer)
pLngth = value
End Set
End Property
===================
so right here ...
inside this instance of Tooth class ...
... how can I discover if the parent Mammal is a Carnivore?
===================
End Class
'-------------------------------------------------------------
Last edited by volking; February 23rd, 2009 at 12:22 PM.
Reason: Text lost indentation - tried to put it back - arrrrrgh!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|