You have to instantiate
List2
. Declaring it does not instantiate it. See
Private _dddd As List2 = New List2
in the
Public Class List1
below.
Don't forget that you will have to instantiate
List1
, also.
In your nested For..Next loops, you are treating your classes as though they are arrays that have been declared with a set number of array cells. Nowhere in your classes do you allocate cells to hold the values that you are assigning in your For..Next loop.
See the Microsoft documentation for
List <t> Class[
^] for ideas on some of the "features" that your List classes must support.
Public Class List1
Private _aaaa As String
Private _bbbb As String
Private _dddd As List2 = New List2
Public Property aaaa() As String
Get
Return _aaaa
End Get
Set(ByVal value As String)
_aaaa = value
End Set
End Property
Public Property bbbb() As String
Get
Return _bbbb
End Get
Set(ByVal value As String)
_bbbb = value
End Set
End Property
Public Property dddd As List2
Get
Return _dddd
End Get
Set(ByVal value As List2)
_dddd = value
End Set
End Property
End Class