1

我得到这个的代码块是,

 If userID > 0 Then
            Dim lq As New lqDFDataContext
            Dim var = lq.mobile_GetCustomChannels(userID).ToList()
            For Each c In var
                Dim channel As New SimpleChannel
                channel.channelID = c.channelID
                channel.userID = c.userID

                If c.matchTitle = True Then
                    channel.matchBy = "Title"
                End If

                If c.matchTitleAbstract = True Then
                    channel.matchBy = "Title and Abstract"
                End If

                If c.fromMyPage = True Then
                    channel.source = "My Page"
                Else
                    channel.source = "All Journals"
                End If

                   Dim tempKW() As String = c.keywords.Split(",")
                For Each kw As String In tempKW
                    channel.keywords.Add(kw)
                Next

                Dim imageKW As String = c.keywords.Substring(0, c.keywords.IndexOf(" "))
                channel.imageURL = SingleImageSearch(imageKW)


                result.Add(channel)
            Next
        End If

“channel.keywords.Add(kw)”这一行是错误出现的地方。我已经使用这种技术数十次没有问题,这似乎与我使用它的所有其他时间相似,但我不断收到此异常。想不通为什么。

4

1 回答 1

1

看起来您的SimpleChannel构造函数没有初始化keywords集合。确保构造函数实际上正在创建keywords(即:keywords = new List(Of String)或任何适当的)的实例。

于 2012-08-22T18:50:16.743 回答