Horje
C# .NET Core linq Distinct Code Example
C# .NET Core linq Distinct
var distinctUsers = allUsers
    .GroupBy(x => x.UserId)
    .Select(x => x.First())
    .ToList();
c# distinct comparer multiple properties
List<Person> distinctPeople = allPeople
  .GroupBy(p => new {p.PersonId, p.FavoriteColor} )
  .Select(g => g.First())
  .ToList();
c# distinct comparer multiple properties
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;
        }
    }
}




Csharp

Related
unity create gameobject from prefab in script Code Example unity create gameobject from prefab in script Code Example
how to check if control key is pressed c# Code Example how to check if control key is pressed c# Code Example
regex c# password numbers and letters Code Example regex c# password numbers and letters Code Example
c# bool to int Code Example c# bool to int Code Example
C# HttpClient POST request Code Example C# HttpClient POST request Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10