Visual Basic .Contains()Null Exception

时间:2016-12-06 10:57:33

标签: vb.net basic

这是我的代码

            Dim words(0) As String
            Dim trie As String
            Dim temp As String
            For i = 1 To 26
                trie = encrypt(a, -i)
                Console.WriteLine(trie)
                For j = 0 To words.Length - 1
                    temp = words(j)
                    If trie.Contains(temp) Then
                        Console.ReadLine()
                    End If
                Next
            Next

它应检查trie是否包含数组字中的任何项,但它会引发NULL异常。

encrypt(a, -i)只是更改字符串中的字母

1 个答案:

答案 0 :(得分:0)

您必须检查这些变量是否为空:

GGRAPH