convert list<list<string>> to dictionary<list<string>,int>
Dic开发者_如何学Gotionary<List<string>, int> dictionary = input.GroupBy(x => x).ToDictionary(x => x.Key, x =>x.Count());
This isn't working, what should I be doing? GroupBy only compares references of list.So how can I compare elements of list?
input is in List< List < string >> and i need it in a dictionary.
Try this
Dictionary<List<string>, int> dictionary = str.GroupBy(x => x).ToDictionary(x => x.Key, x =>x.Key.Count);
Try this
Dictionary<string, int> dictionary = input.GroupBy(x => x).ToDictionary(x => x.Key.toString(), x =>x.Count());
精彩评论