C# use lambda to Group Array and select duplicated record

var serialArr = (from s in serialLotList where s["serialNo"] != null select s["serialNo"].InnerText).ToArray();
var dupSeri = serialArr.GroupBy(x => x).Where(g => g.Count() > 1).FirstOrDefault();

serialArr will be a string Array, we can use groupby to group it, and dupSeri is which group has more than one record, so this record is duplicated.

猜你喜欢

转载自blog.csdn.net/u010081392/article/details/84341640