我正在尝试创建一个包含带有数组列表的类的列表
示例:book(2).page(4).wordcount(1)= 4
所以我创建了这些:
Public Class plist
Dim _wordcount As String = ""
Public Property wordcount() As String
Get
Return _wordcount
End Get
Set(value As String)
_wordcount = value
End Set
End Property
End Class
Public Class blist
Dim _page As List(Of plist)
Public Property page() As List(Of plist)
Get
Return _page
End Get
Set(value As List(Of plist))
_page = value
End Se
End Property
End Class
然后我创建一个这样的列表:
Dim Book as new list(of blist)
之后,一切似乎都不对
我可以添加一本书:
Book.add(new blist)
但是我在添加页面时出现空引用错误:
Book(0).page.add(new plist)
我可能完全偏离了这里。如果有人能让我走上正轨,我将非常感激。
答案 0 :(得分:3)
您的page
物业支持字段目前是:
Dim _page As List(Of plist)
这意味着列表永远不会被初始化。
应该是
Dim _page As New List(Of plist)