我上课了.
public class Compaints
{
public string CustomerNumber{get; set;},
public string Complaint{get; set}
}
Run Code Online (Sandbox Code Playgroud)
我有一份投诉清单.我需要按customerNumber分组并将其添加到字典中说类型
Dictionary<string, int>- 字符串将是客户编号而int将是计数.
如何在linq中执行此操作?
谢谢.
var countByCustomer = complaints.GroupBy(row => row.CustomerNumber)
.ToDictionary(grp => grp.Key, grp => grp.Count());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
87 次 |
| 最近记录: |