I am trying to do something here with VB, I think I do not understand how to do this. Sorry, I'm not so good at OOP.
I have a few things that I create, and they have two meanings: parent name and child name (yes, actual people!).
So it will be like this:
Public Class Child
Public Property ParentName As String
Public Property ChildName As String
End Class
And then:
Public Class Parent
Public Property ParentName As String
Public Property ChildName() As String
End Class
Then I need to add them to the class Parentswhere the parent can have one or more children.
I start by adding Baby. If this parent child name already exists, simply add the child name to this parent, but if it does not exist, create a new parent (with this child). Then add all parents to the parents collection (with their 1 or more children).
The resulting list will look something like this:
Parents:
- Parent: Jonathan Murray
- Child: Karl Merry
Parent: Kathleen Anderson- Child: Stephen Anderson
- Baby: Deborah Anderson
- Child: Thomas Anderson
Parent: Xu Jing- Child: Liu Ming
- Child: Liu Ning
(pay attention to the last: the names of the parents / children should not coincide - in this case, the children take the name of the father instead of the mother, but we do not indicate the father).
How do I create these class types so that I can add children to the parent, add the parent to the parents, and then guarantee that it will be queried using something like Linq?
thanks in advance.
source
share