c# distinct comparer multiple properties
List<Person> distinctPeople = allPeople
.GroupBy(p => new {p.PersonId, p.FavoriteColor} )
.Select(g => g.First())
.ToList();public static IEnumerable<TSource> DistinctBy<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
{
if (seenKeys.Add(keySelector(element)))
{
yield return element;
}
}
}
Also in C#:
- reverse a string in c#
- how to find a transform unity
- how to add to a list c#
- Microsoft.AspNetCore.Components.Forms.InputSelect`1.TryParseValueFromString(String value, TValue& result, String& validationErrorMessage)
- how to locate a specific element in a list c#
- string format comma c#
- C# Into To Tring Debug.Log
- what type of variable is true or false in c#
- unity making homing missile
- c# lambda expression
- parsing string to int without format exception c#
- create object in c#
- c# sort array
- make string
- how to get component in unity c#
- c# md5 hash file
- c# input integer
- c# quaternion eular calculator
- c# get index of item in list
- c# checksum
- how to redirect to extern page in .net core
- c# changimg to one decimal place
- git set origin
- get string character by index c#