Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 在Visual Basic中检查数组中的任何项是否与另一个数组中的任何项匹配_Arrays_Vb.net_Visual Studio - Fatal编程技术网

Arrays 在Visual Basic中检查数组中的任何项是否与另一个数组中的任何项匹配

Arrays 在Visual Basic中检查数组中的任何项是否与另一个数组中的任何项匹配,arrays,vb.net,visual-studio,Arrays,Vb.net,Visual Studio,我有一个目录,里面有.txt文件。我正在将每个文件的行写入一个数组,需要知道一个文件中的任何行是否与另一个文件中的任何行匹配 示例: If any item in Array1 = any item in Array2 then... For Each foundBaseFile As String In My.Computer.FileSystem.GetFiles _ (DataDir, _ FileIO.SearchOption.SearchTopLevelOnly, "*.

我有一个目录,里面有.txt文件。我正在将每个文件的行写入一个数组,需要知道一个文件中的任何行是否与另一个文件中的任何行匹配

示例:

If any item in Array1 = any item in Array2 then...
For Each foundBaseFile As String In My.Computer.FileSystem.GetFiles _
 (DataDir, _
     FileIO.SearchOption.SearchTopLevelOnly, "*.vpk.txt")
        Dim BaseTextArray = IO.File.ReadAllLines(foundBaseFile)
        For Each foundCheckFile As String In My.Computer.FileSystem.GetFiles _
 (DataDir, _
     FileIO.SearchOption.SearchTopLevelOnly, "*.vpk.txt")
            If Not foundBaseFile = foundCheckFile Then
                Dim CheckTextArray = IO.File.ReadAllLines(foundCheckFile)
                'If any item in CheckTextArray = any item in BaseTextArray then
                '    Do X
                'End If
            End If
        Next
    Next
迄今为止的代码:

If any item in Array1 = any item in Array2 then...
For Each foundBaseFile As String In My.Computer.FileSystem.GetFiles _
 (DataDir, _
     FileIO.SearchOption.SearchTopLevelOnly, "*.vpk.txt")
        Dim BaseTextArray = IO.File.ReadAllLines(foundBaseFile)
        For Each foundCheckFile As String In My.Computer.FileSystem.GetFiles _
 (DataDir, _
     FileIO.SearchOption.SearchTopLevelOnly, "*.vpk.txt")
            If Not foundBaseFile = foundCheckFile Then
                Dim CheckTextArray = IO.File.ReadAllLines(foundCheckFile)
                'If any item in CheckTextArray = any item in BaseTextArray then
                '    Do X
                'End If
            End If
        Next
    Next

谢谢

这应该能奏效

If BaseTextArray.Any(Function(o) CheckTextArray.Contains(o)) Then
  ' Do X

声明两个数组变量

dim arr1() as string
dim arr2() as string
从.txt文件第b行读取值并添加到每个arrarlevel。也可以按vbnewline分割线

然后使用

Array.Indexof() 
方法来查找第一个数组字符串中的值是否存在于其他数组字符串中

If indx >1 then
True
Else
False
end if