vb.net nested class' parent?

C

Craig Buchanan

is there an implicitly-defined Parent property defined for a class that is
nested in another class? i'm looking to simplify my coding.

At this point, i've defined the class as so:

Class Item

Private _SubItem As New SubItem(Me)

'other properties and methods

Class SubItem

Private _Parent As Item

Public ReadOnly Property Parent As Item
Get
Return _Parent
End Get
End Property

Friend Sub New (value as Item)
_Parent=value
End Sub

'other stuff

End Class

End Class

Thanks,

Craig Buchanan
 
T

Tom Shelton

Craig said:
is there an implicitly-defined Parent property defined for a class that is
nested in another class? i'm looking to simplify my coding.

At this point, i've defined the class as so:

Class Item

Private _SubItem As New SubItem(Me)

'other properties and methods

Class SubItem

Private _Parent As Item

Public ReadOnly Property Parent As Item
Get
Return _Parent
End Get
End Property

Friend Sub New (value as Item)
_Parent=value
End Sub

'other stuff

End Class

End Class

Thanks,

Craig Buchanan

There isn't an implicit reference to the containing object. You will
need to pass that in yourself in your nested class's constructor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top