c# - linq query group by in a list of strings -
this question has answer here:
- remove duplicates list<t> in c# 21 answers
i new linq query c#. have list of strings , new list or delete double strings.
list<string> zipcodes = new list<string>(); zipcodes.add("1234"); zipcodes.add("1234"); zipcodes.add("1234"); zipcodes.add("4321"); zipcodes.add("4321"); list<string> groupbyzipcodes = (from zip in zipcodes group zip zip newgroup select newgroup.tolist());
cannot implicitly convert type
'system.collection.generic.ienumarable<system.collections.generic.list<string>'
'system.collections.generic.list<string>
. explicit conversion exists (are missing cast?)
you can use distinct keyword in linq:
var dedupedlist = zipcodes.distinct().tolist();
for more see https://msdn.microsoft.com/en-us/library/vstudio/bb348436(v=vs.100).aspx
Comments
Post a Comment