get distinct list c# linq code example
Example 1: c# distinct comparer multiple properties
List distinctPeople = allPeople
.GroupBy(p => new {p.PersonId, p.FavoriteColor} )
.Select(g => g.First())
.ToList();
Example 2: c# distinct array of objects by values
var uniquePersons = persons.GroupBy(p => p.Email)
.Select(grp => grp.First())
.ToArray();