[英]How can I get a count of how many times a number is present in records in a list using LINQ
I have a list:我有一个清单:
public static List<PhraseSource> phraseSources;
The list has property:该列表具有以下属性:
public int? JishoJlpt { get; set; }
Can anyone tell me how I can get a count of each of the different values of JishoJlpt using LINQ?谁能告诉我如何使用 LINQ 计算 JishoJlpt 的每个不同值?
phraseSources.GroupBy(p => p.JishoJlpt)
.Select(g => new { JishoJlpt: g.Key, Count: g.Count() });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.