Reputation: 379
I have a List<KeyValuePair<string, Records> mylist;
I would like to loop in the list foreach different key value. Something like
foreach(var item in myList.select(/\*query the disctinct values of key here ?*/)
is it possible ? How ?
Upvotes: 1
Views: 1275
Reputation: 48568
You can do
foreach(var item in myList.Select(x => x.Key).Distinct())
{
//Your Logic
}
myList.Select(x => x.Key).Distinct()
would give you distinct Keys and foreach
will loop over them.
Upvotes: 4