Tuesday 28 June 2016

find duplicate record from list in C#

var empIds = empList.Select(x => x.EmployeeId).ToList();

var anyDuplicate = empIds.GroupBy(x => x).Any(grp => grp.Count() > 1);


It return bool value (anyDuplicate==true) if any record will be duplicate.

No comments:

Post a Comment