using System.Collections.Generic;
public static class Extensions
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)))
public static void Main()
List<TypeValue> objs = new List<TypeValue>(){
new TypeValue() { Type = "a", Value = "a1" },
new TypeValue() { Type = "a", Value = "a2" },
new TypeValue() { Type = "b", Value = "b" },
new TypeValue() { Type = "c", Value = "c" },
.Select(x => new TypeValue() {
Value = String.Join(", ", objs.Where(o => o.Type == x.Type).Select(o => o.Value).ToList())
Console.WriteLine(o.Value);