C# .NET Core linq Distinct
C#
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;
}
}
}List<Person> distinctPeople = allPeople
.GroupBy(p => new {p.PersonId, p.FavoriteColor} )
.Select(g => g.First())
.ToList();var distinctUsers = allUsers
.GroupBy(x => x.UserId)
.Select(x => x.First())
.ToList();
Also in C#:
- Title
- getcomponent c#
- Category
- C#
- Title
- countdown script unity
- Category
- C#
- Title
- C# graph api upload file one drive
- Category
- C#
- Title
- c# get the last item in a list
- Category
- C#
- Title
- get waht is differnt between two arrays c#
- Category
- C#
- Title
- c# thread sleep
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- json ignore property c#
- Category
- C#
- Title
- c sharp add item to dictionary
- Category
- C#
- Title
- winforms messagebox with button
- Category
- C#
- Title
- C# colours
- Category
- C#
- Title
- how to find a transform unity
- Category
- C#
- Title
- csharp first element of array
- Category
- C#
- Title
- microsoft.portable.csharp.targets was not found vs 2019
- Category
- C#
- Title
- unity key detection
- Category
- C#
- Title
- image filter
- Category
- C#
- Title
- asp multi select dropdown
- Category
- C#
- Title
- unity set object scale
- Category
- C#
- Title
- how to get value from object in c#
- Category
- C#
- Title
- c# xml file builder
- Category
- C#
- Title
- unity check when clicked on object
- Category
- C#
- Title
- c# enum default
- Category
- C#
- Title
- weakreference tryget c#
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- displayname c#
- Category
- C#
- Title
- how to deactivate objects through scripts in unity
- Category
- C#
- Title
- create object in c#
- Category
- C#
- Title
- c# console delay
- Category
- C#
- Title
- c# group array based on first character
- Category
- C#
- Title
- how to update modal class using dbfirst in asp.net core
- Category
- C#
- Title
- c# inheritance constructor
- Category
- C#
- Title
- c# catch two exceptions in one block
- Category
- C#
- Title
- .net core identity get user id
- Category
- C#
- Title
- unity docs player input
- Category
- C#
- Title
- move file from one folder to another c#
- Category
- C#
- Title
- how to insert into a list c#
- Category
- C#
- Title
- c# get desktop path
- Category
- C#
- Title
- whats a string
- Category
- C#
- Title
- Unity C# instantiate prefab
- Category
- C#
- Title
- unity delete all children
- Category
- C#
- Title
- c# how to refreshyour bindingsource
- Category
- C#
- Title
- unity variable from another script
- Category
- C#
- Title
- how to find the area of a circle
- Category
- C#
- Title
- web api startup add imemory cache object
- Category
- C#
- Title
- how to start an if statement in c#
- Category
- C#
- Title
- https request c#
- Category
- C#
- Title
- check which activity in focus in android
- Category
- C#
- Title
- unity connect to firebase
- Category
- C#
- Title
- wpf textblock line break code behind
- Category
- C#
- Title
- how do i foreach c#
- Category
- C#
- Title
- if entity.is Transient() Update Mvc 5 c#
- Category
- C#
- Title
- unity rotation
- Category
- C#
- Title
- how to turn a string in a char list c#
- Category
- C#
- Title
- c# list tuple
- Category
- C#
- Title
- out parameters c#
- Category
- C#
- Title
- c# webrequest cookies
- Category
- C#
- Title
- unity get child
- Category
- C#
- Title
- unity how to get transform scale
- Category
- C#
- Title
- c# random string
- Category
- C#
- Title
- c# list to string
- Category
- C#
- Title
- debug.log unity
- Category
- C#
- Title
- object escape player unity
- Category
- C#
- Title
- c# param exception
- Category
- C#
- Title
- c# two dimensional array
- Category
- C#
- Title
- c# object to json string
- Category
- C#
- Title
- c# compile into an exe
- Category
- C#
- Title
- access object property C#
- Category
- C#
- Title
- c# how to check if two lists have same values
- Category
- C#
- Title
- for each property in object c#
- Category
- C#
- Title
- leantween id
- Category
- C#
- Title
- prefab gets character transform
- Category
- C#
- Title
- c# index in select
- Category
- C#
- Title
- c# find duplicates in list
- Category
- C#
- Title
- how to make infinite loop in c#
- Category
- C#
- Title
- query associative table ef6
- Category
- C#
- Title
- bundle.config in mvc is missing
- Category
- C#
- Title
- unity3d find y position on navmesh
- Category
- C#
- Title
- c# empty char
- Category
- C#
- Title
- c# arrays of arrays
- Category
- C#
- Title
- unity how to add a bullet impact force
- Category
- C#
- Title
- how to insert <input> datatype <td> in asp.net core table
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- c# repeat string x times
- Category
- C#
- Title
- c# print to console
- Category
- C#
- Title
- .net core convert keycollection to array
- Category
- C#
- Title
- c# change variable types
- Category
- C#
- Title
- list clone - C#
- Category
- C#
- Title
- visual studio C# hintergrund bild ändern
- Category
- C#
- Title
- unity how to change rotation
- Category
- C#
- Title
- winforms timer c#
- Category
- C#
- Title
- how to switch scenes in unity
- Category
- C#
- Title
- viewBag as a list
- Category
- C#
- Title
- c# how to open file explorer
- Category
- C#
- Title
- unity to integer
- Category
- C#
- Title
- asp.net c# set session timeout
- Category
- C#
- Title
- c# dictionary get value by key
- Category
- C#
- Title
- http post request login example asp.net c#
- Category
- C#
- Title
- how to use more than one condition in ef join
- Category
- C#
- Title
- unity get max occurrence in list
- Category
- C#
- Title
- No context type was found in the assembly
- Category
- C#