Files
LaDOSE/LaDOSE.Src/LaDOSE.Service/Helper/DistinctBy.cs
Darkstack aebc60d17f Smash test
test debug

Result

Disctinct by selector
Refactoring Smash/Challonge

Test Resultat

Html for Kiouze
2022-03-19 23:05:13 +01:00

23 lines
544 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
namespace LaDOSE.Business.Helper
{
public static class DataHelper
{
public static IEnumerable<T> DistinctBy<T,TKey>(this IEnumerable<T> lst,Func<T,TKey> dist)
{
var seen = new HashSet<TKey>();
foreach (var e in lst)
{
if (!seen.Contains(dist(e)))
{
seen.Add(dist(e));
yield return e;
}
}
}
}
}