Distinct

public static IEnumerable<T> Distinct<T, TKey>(this IEnumerable<T> @this, Func<T, TKey> keySelector)
{
   return @this.GroupBy( keySelector ).Select( grps => grps ).Select( e => e.First() );
}
Example:
var instrumentSet = _instrumentBag.Distinct(i => i.Name);

Description

Provides a Distinct method that takes a key selector lambda as parameter. The .net framework only provides a Distinct method that takes an instance of an implementation of IEqualityComparer<T> where the standard parameterless Distinct that uses the default equality comparer doesn't suffice.

Details

Double click on the code to select all.

 

;