linq 两个list合并处理,并分组

//两个list合并处理
/unreadMsgList = unreadMsgList.Union(list).ToList();

 //合并处理[MsgCount]
 unreadMsgList.ForEach(c =>
 {
 var group = unreadMsgList.Where(a => a.SenderMark == c.SenderMark);
 c.MsgCount = group.Sum(x => x.MsgCount);
 });

 //去重复
 unreadMsgList = unreadMsgList.Distinct().ToList();

转载于:https://www.cnblogs.com/fyy1003668657/p/10190163.html

你可能感兴趣的:(linq 两个list合并处理,并分组)