您的位置:首页 > 其它

linq快速比较两个列表

2016-02-24 11:36 447 查看
Sub compareLists(ByVal
lst1 As String(), ByVal lst2 As String())

‘通过对话框获取两个药对比文件的数据到两个列表。

Dim ofdg1 As New OpenFileDialog

Dim ofdg2 As New OpenFileDialog

Dim path1 As String = String.Empty

Dim path2 As String = String.Empty

If ofdg1.ShowDialog = vbOK Then

path1 =
ofdg1.FileName

End If

If ofdg2.ShowDialog = vbOK Then

path2 =
ofdg2.FileName

End If

If System.IO.File.Exists(path1) And
System.IO.File.Exists(path2) Then

Dim list1
As String() = System.IO.File.ReadAllLines(path1)

Dim list2
As String() = System.IO.File.ReadAllLines(path2)

compareLists(list1, list2)

End If

Dim differenceQuery = lst1.Except(lst2)

' Execute the query.

For Each name As String In differenceQuery

Debug.Print(name)

Next

End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: