Jon*_*Jon 2 .net c# linq .net-3.5 c#-3.0
我有一个Dictionary<int,List<string>>.
Dictionary<int,List<string>>
我有多个KeyValuePairs所以在第一个KeyValuePair中,List可能有10个项目,第二个KeyValuePair可能有100个等等.
我需要计算每个列表中所有项目的总计数,所以在上面的例子中,我的结果是110.
Jon*_*eet 12
这很简单:
int sum = dictionary.Sum(x => x.Value.Count);
归档时间:
15 年,2 月 前
查看次数:
3156 次
最近记录:
9 年 前