I have been working with a string[]
array in C# that gets returned from a function call. I could possibly cast to a Generic
collection, but I was w
Generic Extension method :
public static IEnumerable Distinct(this IEnumerable source, IEqualityComparer comparer)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
HashSet set = new HashSet(comparer);
foreach (TSource item in source)
{
if (set.Add(item))
{
yield return item;
}
}
}