Enumerable.ToHashSet Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ToHashSet<TSource>(IEnumerable<TSource>) |
Creates a HashSet<T> from an IEnumerable<T>. |
ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>) |
Creates a HashSet<T> from an IEnumerable<T> using the |
ToHashSet<TSource>(IEnumerable<TSource>)
- Source:
- ToCollection.cs
- Source:
- ToCollection.cs
- Source:
- ToCollection.cs
Creates a HashSet<T> from an IEnumerable<T>.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::HashSet<TSource> ^ ToHashSet(System::Collections::Generic::IEnumerable<TSource> ^ source);
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source);
static member ToHashSet : seq<'Source> -> System.Collections.Generic.HashSet<'Source>
<Extension()>
Public Function ToHashSet(Of TSource) (source As IEnumerable(Of TSource)) As HashSet(Of TSource)
Type Parameters
- TSource
The type of the elements of source
.
Parameters
- source
- IEnumerable<TSource>
An IEnumerable<T> to create a HashSet<T> from.
Returns
A HashSet<T> that contains values of type TSource
selected from the input sequence.
Exceptions
source
is null
.
See also
Applies to
ToHashSet<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)
- Source:
- ToCollection.cs
- Source:
- ToCollection.cs
- Source:
- ToCollection.cs
Creates a HashSet<T> from an IEnumerable<T> using the comparer
to compare keys.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::HashSet<TSource> ^ ToHashSet(System::Collections::Generic::IEnumerable<TSource> ^ source, System::Collections::Generic::IEqualityComparer<TSource> ^ comparer);
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource>? comparer);
public static System.Collections.Generic.HashSet<TSource> ToHashSet<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource> comparer);
static member ToHashSet : seq<'Source> * System.Collections.Generic.IEqualityComparer<'Source> -> System.Collections.Generic.HashSet<'Source>
<Extension()>
Public Function ToHashSet(Of TSource) (source As IEnumerable(Of TSource), comparer As IEqualityComparer(Of TSource)) As HashSet(Of TSource)
Type Parameters
- TSource
The type of the elements of source
.
Parameters
- source
- IEnumerable<TSource>
An IEnumerable<T> to create a HashSet<T> from.
- comparer
- IEqualityComparer<TSource>
An IEqualityComparer<T> to compare keys.
Returns
A HashSet<T> that contains values of type TSource
selected from the input sequence.
Exceptions
source
is null
.
See also
Applies to
Σχόλια
https://aka.ms/ContentUserFeedback.
Σύντομα διαθέσιμα: Καθ' όλη τη διάρκεια του 2024 θα καταργήσουμε σταδιακά τα ζητήματα GitHub ως μηχανισμό ανάδρασης για το περιεχόμενο και θα το αντικαταστήσουμε με ένα νέο σύστημα ανάδρασης. Για περισσότερες πληροφορίες, ανατρέξτε στο θέμα:Υποβολή και προβολή σχολίων για