Snippet
C# Find Duplicate Array Values
Use LINQ GroupBy to count how many times each value appears in an integer array.
private Dictionary<int, int> GetArrayDuplicates(int[] arrayToSearch)
{
Dictionary<int, int> counts = arrayToSearch.GroupBy(arrayItem => arrayItem)
.ToDictionary(groupedItem => groupedItem.Key,
groupedItem => groupedItem.Count());
return counts;1 min read#.NET#C#