0
Public Function checkForChars(ByVal arrayOfChars As String(), ByVal stringToCheck As String) As Boolean
        Dim i As Integer
        Dim numEntries As Integer = arrayOfChars.Length - 1
        For i = 0 To numEntries
            If (stringToCheck.Contains(arrayOfChars(numEntries)) = True) Then
                Return True
            End If
        Next

        Return False

End Function

嘿,我正在使用上面的函数来检查字符串中的字符数组,但是如果字符串太长,则会出现算术溢出错误(表明我已经除以 0)。目前我实际上使用的是整数 value.toString,有人可以对此有所了解吗?

谢谢

4

1 回答 1

1

您的代码有一些问题,我已经对其进行了一些修改。检查它是否适合你

Public Function checkForChars(arrayOfChars As String(), stringToCheck As String) As Boolean
    For i As Integer = 0 To arrayOfChars.Length - 1
        If stringToCheck.Contains(arrayOfChars(i)) Then
            Return True
        End If
    Next

    Return False
End Function
于 2013-11-01T11:05:11.760 回答