Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# distinct comparer multiple properties

List<Person> distinctPeople = allPeople
  .GroupBy(p => new {p.PersonId, p.FavoriteColor} )
  .Select(g => g.First())
  .ToList();
Comment

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;
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: remove control characters from string c# 
Csharp :: Transpose Matrix C Sharp 
Csharp :: ado stands for 
Csharp :: animation not playing unity 
Csharp :: user input to array object c# 
Csharp :: unity animation length 
Csharp :: Proxy in Config 
Csharp :: unity read console log 
Csharp :: c# async task constructor 
Csharp :: c# sequential struct with fixed array size 
Csharp :: non null array length 
Csharp :: exit form esc winforms 
Csharp :: unity color mix 
Csharp :: if session is not active then redirect to login page mvc.net 
Csharp :: c# predicate 
Csharp :: How do I identify the referrer page in ASP.NET? 
Csharp :: c++ printwindow chrome 
Csharp :: unity firebase update nodes rank value by sorting value 
Csharp :: VSIX Project Context Menu 
Csharp :: Working with null values 
Csharp :: c# .net RemoveClaim auth 
Csharp :: conditional middleware .net core 
Csharp :: get datacontext of itemscontrol item c# 
Csharp :: aps.net core mvc chek box 
Csharp :: list to array f# 
Csharp :: allelrt box wpf 
Csharp :: c# is file closed 
Csharp :: string with starting zero to int c# 
Csharp :: select startup item visual studio 2019 
Csharp :: what error code i should return in asp.net core whether user name or password are incorrect 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =