开发者

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());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜