我有一个customers
我试图在其中查找重复客户的列表(字符串)。
If Not customers.Count = customers.Distinct.ToList.Count Then
customers = customers.Except(customers.Distinct.ToList)
End If
但我得到以下异常:
InvalidCastException
Unable to cast object of type '<ExceptIterator>d__99`1[System.String]' to type
'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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)