我有一个客户List(字符串),我试图找到重复的客户. If Not customers.Count = customers.Distinct.ToList.Count Then customers = customers.Except(customers.Distinct.ToList)End If 但我得到以下异常: 06001 ‘System.Collec
If Not customers.Count = customers.Distinct.ToList.Count Then customers = customers.Except(customers.Distinct.ToList) End If
但我得到以下异常:
06001
‘System.Collections.Generic.List`1[System.String]’.
这是在列表中查找重复项的正确方法吗?
customers = customers.GroupBy(Function(m) m) _ .Where(Function(g) g.Count() > 1) _ .Select(Function(g) g.Key).ToList