Click or drag to resize

XEnumerableToHashSetTSource Method

Note: This API is now obsolete.

Creates a hash set from the elements in the source sequence.

Namespace:  Linq.Extras
Assembly:  Linq.Extras (in Linq.Extras.dll) Version: 5.0.0+96a4f4bfed64095342c5df107c1fe1fb95603ee5
Syntax
[ObsoleteAttribute("This feature is now implemented directly in System.Linq. Please use Enumerable.ToHashSet instead")]
public static HashSet<TSource> ToHashSet<TSource>(
	IEnumerable<TSource> source,
	IEqualityComparer<TSource>? comparer = null
)

Parameters

source
Type: System.Collections.GenericIEnumerableTSource
The sequence containing the elements to put in the hash set.
comparer (Optional)
Type: System.Collections.GenericIEqualityComparerTSource
A comparer to test for equality between elements.

Type Parameters

TSource
The type of the elements of source.

Return Value

Type: HashSetTSource
A hash set containing the same elements as the source sequence.
Remarks
Since a hash set cannot contain duplicates, duplicate elements from the source sequence will not be included in the hash set.
See Also