<PackageReference Include="System.Collections" Version="4.0.11-beta-23409" />

HashSet<T>

Represents a set of values.To browse the .NET Framework source code for this type, see the Reference Source.

Enumerates the elements of a HashSet<T> object.

public IEqualityComparer<T> Comparer { get; }

Gets the IEqualityComparer<T> object that is used to determine equality for the values in the set.

public int Count { get; }

Gets the number of elements that are contained in a set.

public HashSet()

Initializes a new instance of the HashSet<T> class that is empty and uses the default equality comparer for the set type.

public HashSet(IEqualityComparer<T> comparer)

Initializes a new instance of the HashSet<T> class that is empty and uses the specified equality comparer for the set type.

public HashSet(IEnumerable<T> collection)

Initializes a new instance of the HashSet<T> class that uses the default equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

public HashSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)

Initializes a new instance of the HashSet<T> class that uses the specified equality comparer for the set type, contains elements copied from the specified collection, and has sufficient capacity to accommodate the number of elements copied.

public bool Add(T item)

Adds the specified element to a set.

public void Clear()

Removes all elements from a HashSet<T> object.

public bool Contains(T item)

Determines whether a HashSet<T> object contains the specified element.

public void CopyTo(T[] array, int arrayIndex)

Copies the elements of a HashSet<T> object to an array, starting at the specified array index.

public void CopyTo(T[] array)

Copies the elements of a HashSet<T> object to an array.

public void CopyTo(T[] array, int arrayIndex, int count)

Copies the specified number of elements of a HashSet<T> object to an array, starting at the specified array index.

public void ExceptWith(IEnumerable<T> other)

Removes all elements in the specified collection from the current HashSet<T> object.

Returns an enumerator that iterates through a HashSet<T> object.

public void IntersectWith(IEnumerable<T> other)

Modifies the current HashSet<T> object to contain only elements that are present in that object and in the specified collection.

public bool IsProperSubsetOf(IEnumerable<T> other)

Determines whether a HashSet<T> object is a proper subset of the specified collection.

public bool IsProperSupersetOf(IEnumerable<T> other)

Determines whether a HashSet<T> object is a proper superset of the specified collection.

public bool IsSubsetOf(IEnumerable<T> other)

Determines whether a HashSet<T> object is a subset of the specified collection.

public bool IsSupersetOf(IEnumerable<T> other)

Determines whether a HashSet<T> object is a superset of the specified collection.

public bool Overlaps(IEnumerable<T> other)

Determines whether the current HashSet<T> object and a specified collection share common elements.

public bool Remove(T item)

Removes the specified element from a HashSet<T> object.

public int RemoveWhere(Predicate<T> match)

Removes all elements that match the conditions defined by the specified predicate from a HashSet<T> collection.

public bool SetEquals(IEnumerable<T> other)

Determines whether a HashSet<T> object and the specified collection contain the same elements.

public void SymmetricExceptWith(IEnumerable<T> other)

Modifies the current HashSet<T> object to contain only elements that are present either in that object or in the specified collection, but not both.

public void TrimExcess()

Sets the capacity of a HashSet<T> object to the actual number of elements it contains, rounded up to a nearby, implementation-specific value.

public void UnionWith(IEnumerable<T> other)

Modifies the current HashSet<T> object to contain all elements that are present in itself, the specified collection, or both.