[英]convert list<list<string>> to dictionary<list<string>,int>
Dictionary<List<string>, int> dictionary = input.GroupBy(x => x).ToDictionary(x => x.Key, x =>x.Count());
這不起作用,我該怎么辦? GroupBy 只比較列表的引用。那么如何比較列表的元素呢?
輸入在 List< List < string >> 中,我需要它在字典中。
嘗試這個
Dictionary<List<string>, int> dictionary = str.GroupBy(x => x).ToDictionary(x => x.Key, x =>x.Key.Count);
嘗試這個
Dictionary<string, int> dictionary = input.GroupBy(x => x).ToDictionary(x => x.Key.toString(), x =>x.Count());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.