我在这个简单的代码中遇到了以下问题:
Public Class BookStoreDatabase
Public publicationArray(0 To 3) As String
publicationArray(0) = "Stories to Scare People With"
End Class
bit" publicationArray(0)等"告诉我," publicationArray"是期待。这似乎不应该发生。
答案 0 :(得分:2)
您无法在Class
级别分配数组元素。如果您需要在实例化BookStoreDatabase
类本身后立即分配它,则必须使用构造函数:
Public Class BookStoreDatabase
Public Sub New()
publicationArray(0) = "Stories to Scare People With"
End Sub
Public publicationArray(0 To 3) As String
End Class