我想要实现的是比较索引值。arr1val1和arr2val1,然后是arr1val2和arr2val2,依此类推,前提是它们具有相同数量的索引。最后是一个消息框,无论有多少不匹配,如果在任何比较的索引中检测到不匹配,都会提示。到目前为止,我有这个代码。
Dim str()() As String = _
New String()() {New String() {"arr1val1", "arr1val2"}, New String() {"arr2val1", "arr2val2"}}
For Each arstr As String() In str
For Each strElement As String In arstr
Next
Next
基于您的评论:
Dim mismatchFound = False
For i = 0 To str(0).GetUpperBound(0)
If str(0)(i) <> str(1)(i) Then
mismatchFound = True
Exit For
End If
Next
简洁的方式,即使用LINQ:
Dim mismatchFound = Enumerable.Range(0, str(0).Length).
Any(Function(i) str(0)(i) <> str(1)(i))