TEnumerable.DistinctBy<T,TKey> Method
Overloads
| DistinctBy<T,TKey>(IEnumerable<T>, Func<T,TKey>) |
Returns distinct elements from a sequence according to a specified key selector function. |
| DistinctBy<T,TKey>(IEnumerable<T>, Func<T,TKey>, IEqualityComparer<TKey>) |
Returns distinct elements from a sequence according to a specified key selector function and using a specified comparer to compare keys. |
Returns distinct elements from a sequence according to a specified key selector function.
class function DistinctBy<T,TKey>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>): IEnumerable<T>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of key to distinguish elements by.
Parameters
- source
- IEnumerable<T>
The sequence to remove duplicate elements from.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
Returns
A sequence that contains distinct elements from the source sequence.
Exceptions
source is nil .
Returns distinct elements from a sequence according to a specified key selector function and using a specified comparer to compare keys.
class function DistinctBy<T,TKey>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const comparer: IEqualityComparer<TKey>): IEnumerable<T>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of key to distinguish elements by.
Parameters
- source
- IEnumerable<T>
The sequence to remove duplicate elements from.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- comparer
- IEqualityComparer<TKey>
An equality comparer to compare keys.
Returns
A sequence that contains distinct elements from the source sequence.
Exceptions
source is nil .
Remarks
If comparer is nil , the default equality comparer is
used to compare values.