Check out example codes for "C# .NET Core linq Distinct". It will help you in understanding the concepts better.

Code Example 1

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

Code Example 2

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

Code Example 3

var distinctUsers = allUsers
    .GroupBy(x => x.UserId)
    .Select(x => x.First())
    .ToList();

Learn ReactJs, React Native from akashmittal.com