我有代码检查特定文件,然后如果条件满足,它进入stats.matching ….我使用这个为每个 linq: For Each file As String In From file1 In Stats.FoundFiles Let ftpFile = Utils.ToLowerWithoutSpaces(file1) Where ftpFile.Con
For Each file As String In From file1 In Stats.FoundFiles
Let ftpFile = Utils.ToLowerWithoutSpaces(file1)
Where ftpFile.Contains(currentReportName)
Select file1
Stats.MatchingFiles.Add(file)
Next
问题是如何在这里实施其他方法.
因此,您希望使用不包含该单词的文件填充另一个集合.Dim matching = From file1 In Stats.FoundFiles
Let ftpFile = Utils.ToLowerWithoutSpaces(file1)
Where ftpFile.Contains(currentReportName)
Dim mismatching = From file1 In Stats.FoundFiles
Let ftpFile = Utils.ToLowerWithoutSpaces(file1)
Where Not ftpFile.Contains(currentReportName)
For Each file As String In matching
Stats.MatchingFiles.Add(file)
Next
For Each file As String In mismatching
Stats.MismatchingFiles.Add(file)
Next
这是一个简单的解决方案,您也可以使用更有效的Except:
Dim mismatching = Stats.FoundFiles.Except(matching)
