vb.net判断重复文本并提取
作者:admin 日期:2023-06-22
Dim data As New List(Of String) ' 保存2000000条数据的列表
' 假设数据已经保存在 data 列表中
Dim countDict As New Dictionary(Of String, Integer) ' 字典用于保存每条数据的重复次数
For Each item As String In data
If countDict.ContainsKey(item) Then
countDict(item) += 1 ' 如果字典中已经存在这条数据,重复次数加1
Else
countDict(item) = 1 ' 如果字典中不存在这条数据,添加到字典中并初始化重复次数为1
End If
Next
' 输出重复次数大于1的数据
For Each item As KeyValuePair(Of String, Integer) In countDict
If item.Value > 1 Then
Console.WriteLine("{0}: {1}", item.Key, item.Value)
End If
Next
广告位